summaryrefslogtreecommitdiff
path: root/src/thread
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-07 19:59:32 +0200
committerMax Kellermann <max@musicpd.org>2019-05-07 19:59:32 +0200
commit72fc117393b7b9cf34446ac6b990f344284c43a8 (patch)
treefbfb2af3ffd74f794489209084b1c4a204bbc801 /src/thread
parent230ca2e968e2e4f98e944026413cb7720c7d988b (diff)
thread/WindowsCond: add wait() overload with predicate
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/WindowsCond.hxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/thread/WindowsCond.hxx b/src/thread/WindowsCond.hxx
index 40389512b..7c0b19a1f 100644
--- a/src/thread/WindowsCond.hxx
+++ b/src/thread/WindowsCond.hxx
@@ -63,6 +63,13 @@ public:
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,
std::chrono::steady_clock::duration timeout) noexcept {
auto timeout_ms = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();