]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/ping/ping.cpp
Simplified STG_LOCKER.
[stg.git] / projects / stargazer / plugins / other / ping / ping.cpp
index 00bb362d98151a56b7354cca9dd7922ae03ec2c1..c65a5cbaff805ea9f96f36057e9f277ed63cca5b 100644 (file)
 #include "stg/plugin_creator.h"
 #include "ping.h"
 
-PLUGIN_CREATOR<PING> pc;
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-PLUGIN * GetPlugin()
+namespace
 {
-return pc.GetPlugin();
-}
+PLUGIN_CREATOR<PING> pc;
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ×
 template <typename varType>
-class IS_CONTAINS_USER: public binary_function<varType, USER_PTR, bool>
+class IS_CONTAINS_USER: public std::binary_function<varType, USER_PTR, bool>
 {
 public:
     IS_CONTAINS_USER(const USER_PTR & u) : user(u) {}
     bool operator()(varType notifier) const
         {
         return notifier.GetUser() == user;
-        };
+        }
 private:
     const USER_PTR & user;
 };
+}
+
+extern "C" PLUGIN * GetPlugin();
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+PLUGIN * GetPlugin()
+{
+return pc.GetPlugin();
+}
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 int PING_SETTINGS::ParseSettings(const MODULE_SETTINGS & s)
 {
 PARAM_VALUE pv;
-vector<PARAM_VALUE>::const_iterator pvi;
+std::vector<PARAM_VALUE>::const_iterator pvi;
 
 pv.param = "PingDelay";
 pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv);
@@ -108,6 +114,7 @@ pinger.Start();
 if (pthread_create(&thread, NULL, Run, this))
     {
     errorStr = "Cannot start thread.";
+    logger("Cannot create thread.");
     printfd(__FILE__, "Cannot start thread\n");
     return -1;
     }
@@ -117,7 +124,7 @@ return 0;
 //-----------------------------------------------------------------------------
 int PING::Stop()
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 if (!isRunning)
     return 0;
@@ -137,7 +144,7 @@ for (int i = 0; i < 25; i++)
 users->DelNotifierUserAdd(&onAddUserNotifier);
 users->DelNotifierUserDel(&onDelUserNotifier);
 
-list<USER_PTR>::iterator users_iter;
+std::list<USER_PTR>::iterator users_iter;
 users_iter = usersList.begin();
 while (users_iter != usersList.end())
     {
@@ -169,9 +176,9 @@ long delay = (10000000 * ping->pingSettings.GetPingDelay()) / 3 + 50000000;
  
 while (ping->nonstop)
     {
-    list<USER_PTR>::iterator iter = ping->usersList.begin();
+    std::list<USER_PTR>::iterator iter = ping->usersList.begin();
         {
-        STG_LOCKER lock(&ping->mutex, __FILE__, __LINE__);
+        STG_LOCKER lock(&ping->mutex);
         while (iter != ping->usersList.end())
             {
             if ((*iter)->GetProperty().ips.ConstData().OnlyOneIP())
@@ -232,8 +239,8 @@ void PING::UnSetUserNotifiers(USER_PTR u)
 IS_CONTAINS_USER<CHG_CURRIP_NOTIFIER_PING> IsContainsUserCurrIP(u);
 IS_CONTAINS_USER<CHG_IPS_NOTIFIER_PING> IsContainsUserIP(u);
 
-list<CHG_CURRIP_NOTIFIER_PING>::iterator currIPter;
-list<CHG_IPS_NOTIFIER_PING>::iterator IPIter;
+std::list<CHG_CURRIP_NOTIFIER_PING>::iterator currIPter;
+std::list<CHG_IPS_NOTIFIER_PING>::iterator IPIter;
 
 currIPter = find_if(ChgCurrIPNotifierList.begin(),
                     ChgCurrIPNotifierList.end(),
@@ -261,7 +268,7 @@ if (IPIter != ChgIPNotifierList.end())
 //-----------------------------------------------------------------------------
 void PING::GetUsers()
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 USER_PTR u;
 int h = users->OpenSearch();
@@ -290,7 +297,7 @@ users->CloseSearch(h);
 //-----------------------------------------------------------------------------
 void PING::AddUser(USER_PTR u)
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 SetUserNotifiers(u);
 usersList.push_back(u);
@@ -298,11 +305,11 @@ usersList.push_back(u);
 //-----------------------------------------------------------------------------
 void PING::DelUser(USER_PTR u)
 {
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
 
 UnSetUserNotifiers(u);
 
-list<USER_PTR>::iterator users_iter;
+std::list<USER_PTR>::iterator users_iter;
 users_iter = usersList.begin();
 
 while (users_iter != usersList.end())