thread/*Cond: add wait_for() overload with predicate

This commit is contained in:
Max Kellermann
2019-05-07 19:54:54 +02:00
parent ad4ca0c449
commit 9095167039
3 changed files with 27 additions and 5 deletions

View File

@@ -60,11 +60,7 @@ public:
private:
bool LockWaitFinished() noexcept {
std::unique_lock<Mutex> lock(mutex);
while (!finished)
if (!cond.wait_for(lock, timeout))
return false;
return true;
return cond.wait_for(lock, timeout, [this]{ return finished; });
}
/**