Wakes threads waiting on a Mutex.
More...
#include <StormByte/safe/condition_variable.hxx>
|
| | ConditionVariable () |
| | Condition with no waiters.
|
| | ConditionVariable (const ConditionVariable &)=delete |
| | ConditionVariable (ConditionVariable &&)=delete |
| | ~ConditionVariable () noexcept |
| | Destroys the signal on Base's heap.
|
| ConditionVariable & | operator= (const ConditionVariable &)=delete |
| ConditionVariable & | operator= (ConditionVariable &&)=delete |
| void | notify_one () noexcept |
| | Wake one waiter.
|
| void | notify_all () noexcept |
| | Wake every waiter.
|
| void | wait (UniqueLock &lock) |
| | Wait until notified.
|
| template<class Predicate> |
| void | wait (UniqueLock &lock, Predicate pred) |
| | Wait until pred is true.
|
| template<class Rep, class Period> |
| CvStatus | wait_for (UniqueLock &lock, const std::chrono::duration< Rep, Period > &rel) |
| | Wait until notified or rel elapses.
|
| template<class Rep, class Period, class Predicate> |
| bool | wait_for (UniqueLock &lock, const std::chrono::duration< Rep, Period > &rel, Predicate pred) |
| | Wait until pred is true or rel elapses.
|
| template<class Clock, class Duration> |
| CvStatus | wait_until (UniqueLock &lock, const std::chrono::time_point< Clock, Duration > &abs) |
| | Wait until notified or abs is reached.
|
| template<class Clock, class Duration, class Predicate> |
| bool | wait_until (UniqueLock &lock, const std::chrono::time_point< Clock, Duration > &abs, Predicate pred) |
| | Wait until pred is true or abs is reached.
|
Wakes threads waiting on a Mutex.
Accepts only UniqueLock. The signal lives on Base's heap. A spurious wake is valid. The predicate overloads filter it in the caller.
◆ ConditionVariable() [1/3]
| StormByte::Safe::ConditionVariable::ConditionVariable |
( |
| ) |
|
Condition with no waiters.
- Exceptions
-
◆ ConditionVariable() [2/3]
| StormByte::Safe::ConditionVariable::ConditionVariable |
( |
const ConditionVariable & | | ) |
|
|
delete |
◆ ConditionVariable() [3/3]
| StormByte::Safe::ConditionVariable::ConditionVariable |
( |
ConditionVariable && | | ) |
|
|
delete |
◆ ~ConditionVariable()
| StormByte::Safe::ConditionVariable::~ConditionVariable |
( |
| ) |
|
|
noexcept |
Destroys the signal on Base's heap.
- Note
- No thread may be waiting.
◆ notify_all()
| void StormByte::Safe::ConditionVariable::notify_all |
( |
| ) |
|
|
noexcept |
◆ notify_one()
| void StormByte::Safe::ConditionVariable::notify_one |
( |
| ) |
|
|
noexcept |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ wait() [1/2]
| void StormByte::Safe::ConditionVariable::wait |
( |
UniqueLock & | lock | ) |
|
Wait until notified.
May wake spuriously.
- Parameters
-
| lock | Lock that owns the mutex. Dropped while waiting and retaken before return. |
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait() [2/2]
template<class Predicate>
| void StormByte::Safe::ConditionVariable::wait |
( |
UniqueLock & | lock, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true.
- Template Parameters
-
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock that owns the mutex. |
| pred | Predicate. Evaluated in the caller. |
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_for() [1/2]
template<class Rep, class Period>
| CvStatus StormByte::Safe::ConditionVariable::wait_for |
( |
UniqueLock & | lock, |
|
|
const std::chrono::duration< Rep, Period > & | rel ) |
|
inline |
Wait until notified or rel elapses.
- Template Parameters
-
| Rep | Tick representation of rel. |
| Period | Tick period of rel. |
- Parameters
-
| lock | Lock that owns the mutex. |
| rel | Relative timeout. |
- Returns
- Whether the wait timed out. A spurious wake is CvStatus::NoTimeout.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_for() [2/2]
template<class Rep, class Period, class Predicate>
| bool StormByte::Safe::ConditionVariable::wait_for |
( |
UniqueLock & | lock, |
|
|
const std::chrono::duration< Rep, Period > & | rel, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true or rel elapses.
- Template Parameters
-
| Rep | Tick representation of rel. |
| Period | Tick period of rel. |
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock that owns the mutex. |
| rel | Relative timeout. |
| pred | Predicate. Evaluated in the caller. |
- Returns
- Whether
pred is true on return.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_until() [1/2]
template<class
Clock, class Duration>
| CvStatus StormByte::Safe::ConditionVariable::wait_until |
( |
UniqueLock & | lock, |
|
|
const std::chrono::time_point< Clock, Duration > & | abs ) |
|
inline |
Wait until notified or abs is reached.
- Template Parameters
-
- Parameters
-
| lock | Lock that owns the mutex. |
| abs | Absolute time. |
- Returns
- Whether the wait timed out.
- Precondition
lock owns its mutex.
- Exceptions
-
◆ wait_until() [2/2]
template<class
Clock, class Duration, class Predicate>
| bool StormByte::Safe::ConditionVariable::wait_until |
( |
UniqueLock & | lock, |
|
|
const std::chrono::time_point< Clock, Duration > & | abs, |
|
|
Predicate | pred ) |
|
inline |
Wait until pred is true or abs is reached.
- Template Parameters
-
| Clock | Clock of abs. |
| Duration | Duration of abs. |
| Predicate | Callable invoked with the lock held. Its result is tested as a bool. |
- Parameters
-
| lock | Lock that owns the mutex. |
| abs | Absolute time. |
| pred | Predicate. Evaluated in the caller. |
- Returns
- Whether
pred is true on return.
- Precondition
lock owns its mutex.
- Exceptions
-
The documentation for this class was generated from the following file: