summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/thread.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/thread.h b/src/common/thread.h
index 0cfd98be6..5584c3bf3 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<std::mutex> 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};