ConcurrentQueue: remove redundant checks

The C++ standard specifies `std::condition_variable::wait(lock, pred)`
as equivalent to `while (!pred()) wait(lock);`. It is implemented
exactly so in libstdc++, libc++ and MSVC.
This commit is contained in:
Igor Kushnir 2021-03-18 11:02:07 +02:00 committed by Luis Ángel San Martín
parent 4cb542c8cc
commit 72c78d0164

View File

@ -62,11 +62,7 @@ std::size_t ConcurrentQueue::cancelPending()
void ConcurrentQueue::waitAll()
{
std::unique_lock<std::mutex> lock(jobsLeftMutex);
if (jobsLeft > 0) {
_waitVar.wait(lock, [this] {
return jobsLeft == 0;
});
}
_waitVar.wait(lock, [this] { return jobsLeft == 0; });
}
void ConcurrentQueue::nextJob()
@ -77,10 +73,6 @@ void ConcurrentQueue::nextJob()
{
std::unique_lock<std::mutex> lock(queueMutex);
if (bailout) {
return;
}
jobAvailableVar.wait(lock, [this] {
return _queue.size() > 0 || bailout;
});