27 #include <condition_variable>
31 using namespace std::chrono_literals;
44 std::unique_lock lock(m_mutex);
51 bool Wait(std::chrono::milliseconds timeout = 0s) {
52 std::unique_lock lock(m_mutex);
54 auto t = std::chrono::high_resolution_clock::now() + timeout;
55 auto result = cv.wait_until(lock, t, [&]{
return !is_waiting; });
60 void Wait(
unsigned timeout_ms) {
61 Wait(std::chrono::milliseconds(timeout_ms));
67 std::condition_variable cv;
WaitContinue()
Default constructor, neither copyable nor assignable.
void Continue()
Release any threads blocked by Wait().
void Wait(unsigned timeout_ms)
Blocking wait for next Continue() or timeout (milliseconds)
bool Wait(std::chrono::milliseconds timeout=0s)
Blocking wait for next Continue() with optional timeout.