diff options
author | fanquake <fanquake@gmail.com> | 2021-01-27 15:04:34 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2021-01-29 15:39:44 +0800 |
commit | dc8be12510c2fd5a809d9a82d2c14b464b5e5a3f (patch) | |
tree | b255ae159d9080ec67c8898dae20d1f58a8b4fc7 /src/scheduler.h | |
parent | c8b83510f42c6959c2844b8b81a6590dd3a34e65 (diff) |
refactor: remove boost::thread_group usage
Diffstat (limited to 'src/scheduler.h')
-rw-r--r-- | src/scheduler.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/scheduler.h b/src/scheduler.h index d7fe00d1b4..9eec8c0fa0 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -9,6 +9,7 @@ #include <functional> #include <list> #include <map> +#include <thread> #include <sync.h> @@ -35,6 +36,8 @@ public: CScheduler(); ~CScheduler(); + std::thread m_service_thread; + typedef std::function<void()> Function; /** Call func at/after time t */ @@ -62,8 +65,7 @@ public: void MockForward(std::chrono::seconds delta_seconds); /** - * Services the queue 'forever'. Should be run in a thread, - * and interrupted using boost::interrupt_thread + * Services the queue 'forever'. Should be run in a thread. */ void serviceQueue(); @@ -72,12 +74,14 @@ public: { WITH_LOCK(newTaskMutex, stopRequested = true); newTaskScheduled.notify_all(); + if (m_service_thread.joinable()) m_service_thread.join(); } /** Tell any threads running serviceQueue to stop when there is no work left to be done */ void StopWhenDrained() { WITH_LOCK(newTaskMutex, stopWhenEmpty = true); newTaskScheduled.notify_all(); + if (m_service_thread.joinable()) m_service_thread.join(); } /** |