30#include <condition_variable>
46 using Lock = std::lock_guard<std::mutex>;
47 using ULock = std::unique_lock<std::mutex>;
49 mutable std::mutex m_;
50 mutable std::condition_variable cv_;
87 cv_.wait(ulock, [
this] {
return flag_; });
99 template <
typename Duration>
102 return cv_.wait_for(ulock, dur, [
this] {
return flag_; });
A thread-safe signal mechanism for inter-thread synchronization.
Definition tec_signal.hpp:44
bool wait_for(Duration dur) const
Waits for the signal to be set for a specified duration.
Definition tec_signal.hpp:100
Signal()
Constructs a signal in the unsignaled state.
Definition tec_signal.hpp:58
void set()
Sets the signal to the signaled state and notifies all waiting threads.
Definition tec_signal.hpp:72
void wait() const
Waits indefinitely until the signal is set.
Definition tec_signal.hpp:85
Helper struct to signal termination on exit.
Definition tec_signal.hpp:110
~OnExit()
Destructor that sets the termination signal.
Definition tec_signal.hpp:124
OnExit(Signal *sig)
Constructs an OnExit helper with a termination signal.
Definition tec_signal.hpp:119
Common definitions and utilities for the tec namespace.