]> git.stg.codes - stg.git/blobdiff - projects/stargazer/traffcounter_impl.cpp
Use std::lock_guard instead of STG_LOCKER.
[stg.git] / projects / stargazer / traffcounter_impl.cpp
index a4227497a128e69cbcf27d3150975b5b952657a8..70ade1ae91c2ee941a569a13244ba1dcd5fac0e6 100644 (file)
@@ -40,7 +40,6 @@
 #include <cstdlib> // strtol
 
 #include "stg/common.h"
-#include "stg/locker.h"
 #include "stg/const.h" // MONITOR_TIME_DELAY_SEC
 #include "traffcounter_impl.h"
 #include "stg_timer.h"
@@ -128,9 +127,8 @@ assert(h && "USERS::OpenSearch is always correct");
 m_onIPConns.clear();
 
 //5 seconds to thread stops itself
-struct timespec ts = {0, 200000000};
 for (int i = 0; i < 25 && !stopped; i++)
-    nanosleep(&ts, NULL);
+    std::this_thread::sleep_for(std::chrono::milliseconds(200));
 
 if (!stopped)
 {
@@ -155,10 +153,9 @@ stopped = false;
 int c = 0;
 
 time_t touchTime = stgTime - MONITOR_TIME_DELAY_SEC;
-struct timespec ts = {0, 500000000};
 while (!token.stop_requested())
     {
-    nanosleep(&ts, 0);
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
     if (token.stop_requested())
         {
         FlushAndRemove();