summaryrefslogtreecommitdiff
path: root/src/thread/WindowsCond.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-12-28 21:47:04 +0100
committerMax Kellermann <max@musicpd.org>2016-12-28 21:47:04 +0100
commit871ba5a488683055bcd556610bc974d94984f32f (patch)
treec5580d0ad7394eaa71d0563946498ea68e28d699 /src/thread/WindowsCond.hxx
parent249e8d59cb61e53e517706bfc119d04e590fab13 (diff)
thread/Cond: add timed_wait() overload with std::chrono support
Diffstat (limited to 'src/thread/WindowsCond.hxx')
-rw-r--r--src/thread/WindowsCond.hxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/thread/WindowsCond.hxx b/src/thread/WindowsCond.hxx
index 2ce7271b9..0419ee3c3 100644
--- a/src/thread/WindowsCond.hxx
+++ b/src/thread/WindowsCond.hxx
@@ -32,6 +32,8 @@
#include "CriticalSection.hxx"
+#include <chrono>
+
/**
* Wrapper for a CONDITION_VARIABLE, backend for the Cond class.
*/
@@ -59,6 +61,12 @@ public:
timeout_ms);
}
+ bool timed_wait(CriticalSection &mutex,
+ std::chrono::steady_clock::duration timeout) {
+ auto timeout_ms = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();
+ return timed_wait(mutex, timeout_ms);
+ }
+
void wait(CriticalSection &mutex) {
timed_wait(mutex, INFINITE);
}