19 #ifndef MIR_TEST_SIGNAL_H_ 20 #define MIR_TEST_SIGNAL_H_ 22 #include <gmock/gmock.h> 24 #include <condition_variable> 42 template<
typename rep,
typename period>
43 bool wait_for(std::chrono::duration<rep, period> delay)
45 std::unique_lock<decltype(mutex)> lock(mutex);
46 return cv.wait_for(lock, delay, [
this]() {
return signalled; });
48 template<
class Clock,
class Duration>
49 bool wait_until(std::chrono::time_point<Clock, Duration>
const& time)
51 std::unique_lock<decltype(mutex)> lock(mutex);
52 return cv.wait_until(lock, time, [
this]() {
return signalled; });
59 std::condition_variable cv;
60 bool signalled{
false};
74 if (atomic_int->fetch_sub(1) == 1)
83 #endif // MIR_TEST_SIGNAL_H_ AutoUnblockThread is a helper thread class that can gracefully shutdown at destruction time...
Definition: sw_splash.h:26
bool wait_until(std::chrono::time_point< Clock, Duration > const &time)
Definition: signal.h:49
bool wait_for(std::chrono::duration< rep, period > delay)
Definition: signal.h:43
ACTION_P2(WakeUpWhenZero, signal, atomic_int)
Definition: signal.h:72
ACTION_P(ReturnFalseAndWakeUp, signal)
Definition: signal.h:63
A threadsafe, waitable signal.
Definition: signal.h:35