diff options
author | bunnei <bunneidev@gmail.com> | 2020-01-24 02:18:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-24 02:18:47 +0100 |
commit | deb97f6a8e48c17f8e16efadc24872a860d529a7 (patch) | |
tree | 79ca6164fcb03783bc19f1ec557cacdf0b3fc539 /src/common/thread.h | |
parent | Merge pull request #3341 from bunnei/time-posix-myrule (diff) | |
parent | Replace GetString with Get function (diff) | |
download | yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar.gz yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar.bz2 yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar.lz yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar.xz yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.tar.zst yuzu-deb97f6a8e48c17f8e16efadc24872a860d529a7.zip |
Diffstat (limited to 'src/common/thread.h')
-rw-r--r-- | src/common/thread.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/thread.h b/src/common/thread.h index 0cfd98be6..2fc071685 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -28,6 +28,15 @@ public: is_set = false; } + template <class Duration> + bool WaitFor(const std::chrono::duration<Duration>& time) { + std::unique_lock lk{mutex}; + if (!condvar.wait_for(lk, time, [this] { return is_set; })) + return false; + is_set = false; + return true; + } + template <class Clock, class Duration> bool WaitUntil(const std::chrono::time_point<Clock, Duration>& time) { std::unique_lock lk{mutex}; |