CppCommon
1.0.4.1
C++ Common Library
|
Named condition variable synchronization primitive. More...
#include <named_condition_variable.h>
Public Member Functions | |
NamedConditionVariable (const std::string &name) | |
Default class constructor. More... | |
NamedConditionVariable (const NamedConditionVariable &)=delete | |
NamedConditionVariable (NamedConditionVariable &&cv)=delete | |
~NamedConditionVariable () | |
NamedConditionVariable & | operator= (const NamedConditionVariable &)=delete |
NamedConditionVariable & | operator= (NamedConditionVariable &&cv)=delete |
const std::string & | name () const |
Get the condition variable name. More... | |
void | NotifyOne () |
Notify one of waiting thread about event occurred. More... | |
void | NotifyAll () |
Notify all waiting threads about event occurred. More... | |
void | Wait () |
Wait until condition variable is notified. More... | |
template<typename TPredicate > | |
void | Wait (TPredicate predicate) |
Wait until condition variable is notified using the given predicate. More... | |
bool | TryWaitFor (const Timespan ×pan) |
Try to wait for the given timespan until condition variable is notified. More... | |
template<typename TPredicate > | |
bool | TryWaitFor (const Timespan ×pan, TPredicate predicate) |
Try to wait for the given timespan until condition variable is notified using the given predicate. More... | |
bool | TryWaitUntil (const UtcTimestamp ×tamp) |
Try to wait until the given timestamp until condition variable is notified. More... | |
template<typename TPredicate > | |
bool | TryWaitUntil (const UtcTimestamp ×tamp, TPredicate predicate) |
Try to wait until the given timestamp until condition variable is notified using the given predicate. More... | |
Named condition variable synchronization primitive.
Named condition variable behaves as a simple condition variable but could be shared between processes on the same machine.
Thread-safe.
Definition at line 26 of file named_condition_variable.h.
|
explicit |
Default class constructor.
name | - Condition variable name |
Definition at line 243 of file named_condition_variable.cpp.
|
delete |
|
delete |
CppCommon::NamedConditionVariable::~NamedConditionVariable | ( | ) |
Definition at line 254 of file named_condition_variable.cpp.
const std::string & CppCommon::NamedConditionVariable::name | ( | ) | const |
Get the condition variable name.
Definition at line 260 of file named_condition_variable.cpp.
void CppCommon::NamedConditionVariable::NotifyAll | ( | ) |
Notify all waiting threads about event occurred.
Unblocks all threads currently waiting for this condition. If no threads are waiting, the function does nothing.
Will not block.
Definition at line 263 of file named_condition_variable.cpp.
void CppCommon::NamedConditionVariable::NotifyOne | ( | ) |
Notify one of waiting thread about event occurred.
Unblocks one of the threads currently waiting for this condition. If no threads are waiting, the function does nothing. If more than one, it is unspecified which of the threads is selected.
Will not block.
Definition at line 262 of file named_condition_variable.cpp.
|
delete |
|
delete |
bool CppCommon::NamedConditionVariable::TryWaitFor | ( | const Timespan & | timespan | ) |
Try to wait for the given timespan until condition variable is notified.
The execution of the current thread is blocked during timespan, or until notified (if the latter happens first).
Will block for the given timespan in the worst case.
timespan | - Timespan to wait for the condition variable notification |
Definition at line 267 of file named_condition_variable.cpp.
bool CppCommon::NamedConditionVariable::TryWaitFor | ( | const Timespan & | timespan, |
TPredicate | predicate | ||
) |
Try to wait for the given timespan until condition variable is notified using the given predicate.
This method is equivalent to:
Will block for the given timespan in the worst case.
timespan | - Timespan to wait for the condition variable notification |
predicate | - Predicate to check |
Definition at line 19 of file named_condition_variable.inl.
|
inline |
Try to wait until the given timestamp until condition variable is notified.
The execution of the current thread is blocked either until notified or until timestamp, whichever happens first.
Will block until the given timestamp in the worst case.
timestamp | - Timestamp to stop wait for the condition variable notification |
Definition at line 124 of file named_condition_variable.h.
|
inline |
Try to wait until the given timestamp until condition variable is notified using the given predicate.
This method is equivalent to:
Will block until the given timestamp in the worst case.
timestamp | - Timestamp to stop wait for the condition variable notification |
predicate | - Predicate to check |
Definition at line 140 of file named_condition_variable.h.
void CppCommon::NamedConditionVariable::Wait | ( | ) |
Wait until condition variable is notified.
The execution of the current thread is blocked until notified.
Will block.
Definition at line 265 of file named_condition_variable.cpp.
void CppCommon::NamedConditionVariable::Wait | ( | TPredicate | predicate | ) |
Wait until condition variable is notified using the given predicate.
This method is equivalent to:
Will block.
predicate | - Predicate to check |
Definition at line 12 of file named_condition_variable.inl.