Commit 72fc1173 authored by Max Kellermann's avatar Max Kellermann

thread/WindowsCond: add wait() overload with predicate

parent 230ca2e9
...@@ -63,6 +63,13 @@ public: ...@@ -63,6 +63,13 @@ public:
INFINITE); INFINITE);
} }
template<typename M, typename P>
void wait(std::unique_lock<M> &lock,
P &&predicate) noexcept {
while (!predicate())
wait(lock);
}
bool wait_for(std::unique_lock<CriticalSection> &lock, bool wait_for(std::unique_lock<CriticalSection> &lock,
std::chrono::steady_clock::duration timeout) noexcept { std::chrono::steady_clock::duration timeout) noexcept {
auto timeout_ms = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count(); auto timeout_ms = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment