From 72fc117393b7b9cf34446ac6b990f344284c43a8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 May 2019 19:59:32 +0200 Subject: [PATCH] thread/WindowsCond: add wait() overload with predicate --- src/thread/WindowsCond.hxx | 7 +++++++ 1 file changed, 7 insertions(+) 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 + void wait(std::unique_lock &lock, + P &&predicate) noexcept { + while (!predicate()) + wait(lock); + } + bool wait_for(std::unique_lock &lock, std::chrono::steady_clock::duration timeout) noexcept { auto timeout_ms = std::chrono::duration_cast(timeout).count();