aboutsummaryrefslogtreecommitdiff
path: root/src/scheduler.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2015-05-16 18:02:46 -0400
committerGavin Andresen <gavinandresen@gmail.com>2015-05-16 18:03:26 -0400
commit3c60937ce6a251e565e169715ebb2f3dd76825c4 (patch)
tree4e0779eebaebe0a36bdba23fe6df52ec4a0ed2cc /src/scheduler.h
parentec82d8c99c6dc225d3e55f6a684890142a755443 (diff)
parentf50105486f3a664c3ecd2d7a5552f2767941f4d7 (diff)
Merge pull request #6146
f501054 More robust CScheduler unit test (Gavin Andresen)
Diffstat (limited to 'src/scheduler.h')
-rw-r--r--src/scheduler.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/scheduler.h b/src/scheduler.h
index bb383ab9f9..436659e58b 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -60,11 +60,24 @@ public:
// and interrupted using boost::interrupt_thread
void serviceQueue();
+ // Tell any threads running serviceQueue to stop as soon as they're
+ // done servicing whatever task they're currently servicing (drain=false)
+ // or when there is no work left to be done (drain=true)
+ void stop(bool drain=false);
+
+ // Returns number of tasks waiting to be serviced,
+ // and first and last task times
+ size_t getQueueInfo(boost::chrono::system_clock::time_point &first,
+ boost::chrono::system_clock::time_point &last) const;
+
private:
std::multimap<boost::chrono::system_clock::time_point, Function> taskQueue;
boost::condition_variable newTaskScheduled;
- boost::mutex newTaskMutex;
+ mutable boost::mutex newTaskMutex;
int nThreadsServicingQueue;
+ bool stopRequested;
+ bool stopWhenEmpty;
+ bool shouldStop() { return stopRequested || (stopWhenEmpty && taskQueue.empty()); }
};
#endif