diff options
author | wwylele <wwylele@gmail.com> | 2016-12-11 22:26:23 +0100 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-12-26 09:41:26 +0100 |
commit | 2a069e76a5093db44a87732edb72a1bb2b771e61 (patch) | |
tree | 6f4ee65597dc6ea2b78eb43aa7521b54235dd242 /src/common/thread.h | |
parent | Merge pull request #2369 from MerryMage/core-frontend (diff) | |
download | yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar.gz yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar.bz2 yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar.lz yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar.xz yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.tar.zst yuzu-2a069e76a5093db44a87732edb72a1bb2b771e61.zip |
Diffstat (limited to 'src/common/thread.h')
-rw-r--r-- | src/common/thread.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/thread.h b/src/common/thread.h index 9c08be7e3..fa475ab51 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -4,6 +4,7 @@ #pragma once +#include <chrono> #include <condition_variable> #include <cstddef> #include <mutex> @@ -54,6 +55,15 @@ public: is_set = false; } + template <class Clock, class Duration> + bool WaitUntil(const std::chrono::time_point<Clock, Duration>& time) { + std::unique_lock<std::mutex> lk(mutex); + if (!condvar.wait_until(lk, time, [this] { return is_set; })) + return false; + is_set = false; + return true; + } + void Reset() { std::unique_lock<std::mutex> lk(mutex); // no other action required, since wait loops on the predicate and any lingering signal will |