Auto merge of #4600 - daira:fix-cscheduler, r=daira

Fix bug in CScheduler
This commit is contained in:
Homu 2020-07-13 21:38:06 +00:00
commit 6caed410c0
1 changed files with 6 additions and 3 deletions

View File

@ -40,9 +40,12 @@ void CScheduler::serviceQueue()
// Some boost versions have a conflicting overload of wait_until that returns void.
// Explicitly use a template here to avoid hitting that overload.
while (!shouldStop() && !taskQueue.empty() &&
newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) {
// Keep waiting until timeout
while (!shouldStop() && !taskQueue.empty())
{
auto copy = taskQueue.begin()->first;
if (newTaskScheduled.wait_until<>(lock, copy) == boost::cv_status::timeout) {
break;
}
}
// If there are multiple threads, the queue can empty while we're waiting (another