Permalink
Browse files

Expose if CScheduler is being serviced, assert its not in EmptyQueue

  • Loading branch information...
1 parent 3192975 commit 1f668b646806f94acd851acdbd9939c24e0492d3 @TheBlueMatt TheBlueMatt committed Jul 11, 2017
Showing with 9 additions and 0 deletions.
  1. +5 −0 src/scheduler.cpp
  2. +4 −0 src/scheduler.h
View
@@ -140,6 +140,10 @@ size_t CScheduler::getQueueInfo(boost::chrono::system_clock::time_point &first,
return result;
}
+bool CScheduler::AreThreadsServicingQueue() const {
+ return nThreadsServicingQueue;
+}
+
void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() {
{
@@ -193,6 +197,7 @@ void SingleThreadedSchedulerClient::AddToProcessQueue(std::function<void (void)>
}
void SingleThreadedSchedulerClient::EmptyQueue() {
+ assert(!m_pscheduler->AreThreadsServicingQueue());
bool should_continue = true;
while (should_continue) {
ProcessQueue();
View
@@ -71,6 +71,9 @@ class CScheduler
size_t getQueueInfo(boost::chrono::system_clock::time_point &first,
boost::chrono::system_clock::time_point &last) const;
+ // Returns true if there are threads actively running in serviceQueue()
+ bool AreThreadsServicingQueue() const;
+
private:
std::multimap<boost::chrono::system_clock::time_point, Function> taskQueue;
boost::condition_variable newTaskScheduled;
@@ -103,6 +106,7 @@ class SingleThreadedSchedulerClient {
void AddToProcessQueue(std::function<void (void)> func);
// Processes all remaining queue members on the calling thread, blocking until queue is empty
+ // Must be called after the CScheduler has no remaining processing threads!
void EmptyQueue();
};

0 comments on commit 1f668b6

Please sign in to comment.