DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Helper class to communicate flags between different threads based on a condition variable and a mutex. Two threads make use of the same instance of this class. One of the thread awaits a flag to be set by the other thread. More...
Public Member Functions | |
OneToOneNotifier () | |
~OneToOneNotifier () | |
bool | Wait (const std::chrono::milliseconds Timeout=std::chrono::milliseconds(0)) |
Makes current thread wait until it is notified or until given timeout duration is exceeded. Destructor might be called while Wait() is waiting (the waiting thread will be notified then). Wait() must not be called (of course) while destructor is running. More... | |
void | Notify () |
Set notification to stop waiting (sets EventOccurred to true). More... | |
void | Ignore () |
Ignore last notification (sets EventOccurred to false). More... | |
Public Member Functions inherited from Util::INonCopyable | |
INonCopyable (const INonCopyable &)=delete | |
INonCopyable & | operator= (const INonCopyable &)=delete |
Private Attributes | |
bool | EventOccurred |
bool | SomeoneIsWaiting |
std::atomic< bool > | MutexCanBeDestroyed |
std::mutex | Mutex |
std::condition_variable | ConditionVariable |
Additional Inherited Members | |
Protected Member Functions inherited from Util::INonCopyable | |
constexpr | INonCopyable ()=default |
~INonCopyable ()=default | |
Helper class to communicate flags between different threads based on a condition variable and a mutex. Two threads make use of the same instance of this class. One of the thread awaits a flag to be set by the other thread.
void Util::OneToOneNotifier::Ignore | ( | ) |
void Util::OneToOneNotifier::Notify | ( | ) |
bool Util::OneToOneNotifier::Wait | ( | const std::chrono::milliseconds | Timeout = std::chrono::milliseconds(0) | ) |
Makes current thread wait until it is notified or until given timeout duration is exceeded. Destructor might be called while Wait() is waiting (the waiting thread will be notified then). Wait() must not be called (of course) while destructor is running.
Timeout | Time to wait for a notification. 0 ms means that the functions waits without timing out ever. |
InvalidCallException | is thrown if a thread is already waiting for this notifier. |
|
private |
|
private |