aboutsummaryrefslogtreecommitdiff
path: root/src/scheduler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/scheduler.h')
-rw-r--r--src/scheduler.h8
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();
}
/**