Add JobQueue::rendezvous

This commit is contained in:
Vinnie Falco
2016-02-23 11:33:01 -05:00
parent e8b75b80c2
commit 73df97f2d0
3 changed files with 25 additions and 3 deletions

View File

@@ -305,6 +305,17 @@ JobQueue::getJson (int c)
return ret;
}
void
JobQueue::rendezvous()
{
std::unique_lock<std::mutex> lock(m_mutex);
cv_.wait(lock, [&]
{
return m_processCount == 0 &&
m_jobSet.empty();
});
}
JobTypeData&
JobQueue::getJobTypeData (JobType type)
{
@@ -476,11 +487,12 @@ JobQueue::processTask ()
{
std::lock_guard <std::mutex> lock (m_mutex);
finishJob (type);
--m_processCount;
// Job should be destroyed before calling checkStopped
// otherwise destructors with side effects can access
// parent objects that are already destroyed.
finishJob (type);
if(--m_processCount == 0 && m_jobSet.empty())
cv_.notify_all();
checkStopped (lock);
}