mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-12 08:08:25 +00:00
Expose if CScheduler is being serviced, assert its not in EmptyQueue
This commit is contained in:
parent
3192975f1d
commit
1f668b6468
@ -140,6 +140,10 @@ size_t CScheduler::getQueueInfo(boost::chrono::system_clock::time_point &first,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CScheduler::AreThreadsServicingQueue() const {
|
||||||
|
return nThreadsServicingQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() {
|
void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() {
|
||||||
{
|
{
|
||||||
@ -193,6 +197,7 @@ void SingleThreadedSchedulerClient::AddToProcessQueue(std::function<void (void)>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SingleThreadedSchedulerClient::EmptyQueue() {
|
void SingleThreadedSchedulerClient::EmptyQueue() {
|
||||||
|
assert(!m_pscheduler->AreThreadsServicingQueue());
|
||||||
bool should_continue = true;
|
bool should_continue = true;
|
||||||
while (should_continue) {
|
while (should_continue) {
|
||||||
ProcessQueue();
|
ProcessQueue();
|
||||||
|
@ -71,6 +71,9 @@ public:
|
|||||||
size_t getQueueInfo(boost::chrono::system_clock::time_point &first,
|
size_t getQueueInfo(boost::chrono::system_clock::time_point &first,
|
||||||
boost::chrono::system_clock::time_point &last) const;
|
boost::chrono::system_clock::time_point &last) const;
|
||||||
|
|
||||||
|
// Returns true if there are threads actively running in serviceQueue()
|
||||||
|
bool AreThreadsServicingQueue() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::multimap<boost::chrono::system_clock::time_point, Function> taskQueue;
|
std::multimap<boost::chrono::system_clock::time_point, Function> taskQueue;
|
||||||
boost::condition_variable newTaskScheduled;
|
boost::condition_variable newTaskScheduled;
|
||||||
@ -103,6 +106,7 @@ public:
|
|||||||
void AddToProcessQueue(std::function<void (void)> func);
|
void AddToProcessQueue(std::function<void (void)> func);
|
||||||
|
|
||||||
// Processes all remaining queue members on the calling thread, blocking until queue is empty
|
// 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();
|
void EmptyQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user