diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-28 21:47:04 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-28 21:47:04 +0100 |
commit | 871ba5a488683055bcd556610bc974d94984f32f (patch) | |
tree | c5580d0ad7394eaa71d0563946498ea68e28d699 /src/thread/WindowsCond.hxx | |
parent | 249e8d59cb61e53e517706bfc119d04e590fab13 (diff) |
thread/Cond: add timed_wait() overload with std::chrono support
Diffstat (limited to 'src/thread/WindowsCond.hxx')
-rw-r--r-- | src/thread/WindowsCond.hxx | 8 |
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); } |