Condition variable wrapping std::condition_variable. More...
#include <waitcondition.h>
Public Member Functions | |
| WaitCondition ()=default | |
| Constructs a WaitCondition. | |
| ~WaitCondition ()=default | |
| Destructor. | |
| WaitCondition (const WaitCondition &)=delete | |
| WaitCondition & | operator= (const WaitCondition &)=delete |
| WaitCondition (WaitCondition &&)=delete | |
| WaitCondition & | operator= (WaitCondition &&)=delete |
| Error | wait (Mutex &mutex, unsigned int timeoutMs=0) |
| Waits until woken or the timeout expires. | |
| template<typename Predicate , typename = std::enable_if_t<std::is_invocable_r_v<bool, Predicate>>> | |
| Error | wait (Mutex &mutex, Predicate pred, unsigned int timeoutMs=0) |
| Waits until a predicate becomes true or the timeout expires. | |
| void | wakeOne () |
| Wakes one waiting thread. | |
| void | wakeAll () |
| Wakes all waiting threads. | |
Condition variable wrapping std::condition_variable.
Used with Mutex to allow threads to wait for a condition to become true. Non-copyable and non-movable.
Waits until a predicate becomes true or the timeout expires.
The caller must hold mutex locked. The mutex is atomically released while waiting and re-acquired before returning.
| Predicate | A callable returning bool. |
| mutex | The mutex to wait on. |
| pred | The predicate to check. |
| timeoutMs | Maximum time to wait in milliseconds. A value of 0 (the default) waits indefinitely. |
Waits until woken or the timeout expires.
The caller must hold mutex locked. The mutex is atomically released while waiting and re-acquired before returning.
| mutex | The mutex to wait on. |
| timeoutMs | Maximum time to wait in milliseconds. A value of 0 (the default) waits indefinitely. |