]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/ping/ping.h
Use std::jthread and C++17.
[stg.git] / projects / stargazer / plugins / other / ping / ping.h
index 9986be39ff75f493a70d166c3639ce9986c93af0..23874e37623da45d03fd35fb30a0919d1889af80 100644 (file)
 
 #include <string>
 #include <list>
+#include <mutex>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#include <jthread.hpp>
+#pragma GCC diagnostic pop
 #include <cstdint>
 
-#include <pthread.h>
-
 class PING;
 
 namespace STG
@@ -118,7 +121,7 @@ private:
     void GetUsers();
     void SetUserNotifiers(UserPtr u);
     void UnSetUserNotifiers(UserPtr u);
-    static void * Run(void * d);
+    void Run(std::stop_token token);
 
     mutable std::string errorStr;
     PING_SETTINGS pingSettings;
@@ -126,9 +129,8 @@ private:
     STG::Users * users;
     std::list<UserPtr> usersList;
 
-    pthread_t thread;
-    pthread_mutex_t mutex;
-    bool nonstop;
+    std::jthread m_thread;
+    std::mutex m_mutex;
     bool isRunning;
     mutable STG_PINGER pinger;