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...
#include <Util.h>
|
| 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.
|
|
void | Notify () |
| Set notification to stop waiting (sets EventOccurred to true).
|
|
void | Ignore () |
| Ignore last notification (sets EventOccurred to false).
|
|
| INonCopyable (const INonCopyable &)=delete |
|
INonCopyable & | operator= (const INonCopyable &)=delete |
|
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.
Definition at line 264 of file Util.h.
◆ OneToOneNotifier()
Util::OneToOneNotifier::OneToOneNotifier |
( |
| ) |
|
|
inline |
◆ ~OneToOneNotifier()
Util::OneToOneNotifier::~OneToOneNotifier |
( |
| ) |
|
◆ Ignore()
void Util::OneToOneNotifier::Ignore |
( |
| ) |
|
Ignore last notification (sets EventOccurred to false).
Definition at line 79 of file Util.cpp.
◆ Notify()
void Util::OneToOneNotifier::Notify |
( |
| ) |
|
Set notification to stop waiting (sets EventOccurred to true).
Definition at line 69 of file Util.cpp.
◆ Wait()
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.
- Parameters
-
Timeout | Time to wait for a notification. 0 ms means that the functions waits without timing out ever. |
- Returns
- Returns true if the function returned due to an exceeded timeout duration. Returns false if the function returned due to the OneToOneNotifier having been notified.
- Exceptions
-
Definition at line 39 of file Util.cpp.
◆ ConditionVariable
std::condition_variable Util::OneToOneNotifier::ConditionVariable |
|
private |
◆ EventOccurred
bool Util::OneToOneNotifier::EventOccurred |
|
private |
◆ Mutex
std::mutex Util::OneToOneNotifier::Mutex |
|
private |
◆ MutexCanBeDestroyed
std::atomic<bool> Util::OneToOneNotifier::MutexCanBeDestroyed |
|
private |
◆ SomeoneIsWaiting
bool Util::OneToOneNotifier::SomeoneIsWaiting |
|
private |
The documentation for this class was generated from the following files: