mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
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:
parent
4cb542c8cc
commit
72c78d0164
@ -62,11 +62,7 @@ std::size_t ConcurrentQueue::cancelPending()
|
|||||||
void ConcurrentQueue::waitAll()
|
void ConcurrentQueue::waitAll()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(jobsLeftMutex);
|
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()
|
void ConcurrentQueue::nextJob()
|
||||||
@ -77,10 +73,6 @@ void ConcurrentQueue::nextJob()
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(queueMutex);
|
std::unique_lock<std::mutex> lock(queueMutex);
|
||||||
|
|
||||||
if (bailout) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jobAvailableVar.wait(lock, [this] {
|
jobAvailableVar.wait(lock, [this] {
|
||||||
return _queue.size() > 0 || bailout;
|
return _queue.size() > 0 || bailout;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user