From 1f668b646806f94acd851acdbd9939c24e0492d3 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 10 Jul 2017 21:08:19 -0400 Subject: Expose if CScheduler is being serviced, assert its not in EmptyQueue --- src/scheduler.cpp | 5 +++++ src/scheduler.h | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 35bf0da4be..36a6d5110d 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -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 SingleThreadedSchedulerClient::EmptyQueue() { + assert(!m_pscheduler->AreThreadsServicingQueue()); bool should_continue = true; while (should_continue) { ProcessQueue(); diff --git a/src/scheduler.h b/src/scheduler.h index 6a079f7749..0365d668b2 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -71,6 +71,9 @@ public: 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 taskQueue; boost::condition_variable newTaskScheduled; @@ -103,6 +106,7 @@ public: void AddToProcessQueue(std::function 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(); }; -- cgit v1.2.3