Fix bug in CScheduler

This commit is contained in:
Taylor Hornby 2020-06-11 12:27:45 -06:00 committed by Daira Hopwood
parent 552482a404
commit daf9ed98a1
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