B2BITS FIX Antenna C++  2.31.0
Public Member Functions | List of all members
System::Condition Class Reference

Condition class provides communication, the ability to wait for some shared resource to reach some desired state, or to signal that it has reached some state in which another thread may be interested. More...

#include <B2BITS_Condition.h>

Public Member Functions

void broadcast ()
 Broadcasts condition, waking all current waiters. More...
 
 Condition ()
 Constructor. More...
 
void signal ()
 Signals condition, waking one waiting thread. More...
 
bool timedWait (Mutex *apMutex, u64 aTimeout)
 Waits on condition, until awaked by a signal or broadcast, or until a specified amount of time has elapsed. More...
 
void wait (Mutex *apMutex)
 Waits on condition, until awakened by a signal or broadcast. More...
 
 ~Condition ()
 Destructor. More...
 

Detailed Description

Condition class provides communication, the ability to wait for some shared resource to reach some desired state, or to signal that it has reached some state in which another thread may be interested.

Each condition variable is closely associated with a mutex that protects the state of the resource.

Note
A conditional variable wait always returns with the mutex locked.
Warning
Conditional variables are for signaling, not for mutual exclusion.
Note
Conditional variables and thier predicates are "linked" - for best results, treat them that way!

Constructor & Destructor Documentation

◆ Condition()

System::Condition::Condition ( )

Constructor.

Exceptions
SystemException

◆ ~Condition()

System::Condition::~Condition ( )

Destructor.

Member Function Documentation

◆ broadcast()

void System::Condition::broadcast ( )

Broadcasts condition, waking all current waiters.

Note
Use when more than one waiter may respond to predicate change or if any waiting thread may not be able to respond.
Exceptions
SystemException

◆ signal()

void System::Condition::signal ( )

Signals condition, waking one waiting thread.

Note
Use when any waiter can respond, and only one need respond. All waiters are equal.
Exceptions
SystemException

◆ timedWait()

bool System::Condition::timedWait ( Mutex apMutex,
u64  aTimeout 
)

Waits on condition, until awaked by a signal or broadcast, or until a specified amount of time has elapsed.

If awaked by a signal or broadcast returns true, otherwise false. The current thread must own specified mutex.

Note
The function shall block on a condition variable. It shall be called with mutex locked by the calling thread or undefined behavior results. Upon successful return, the mutex shall have been locked and shall be owned by the calling thread.
Parameters
aTimeoutthe maximum time to wait in milliseconds.
apMutexSystem::Mutex object on which to wait.
Exceptions
SystemException

◆ wait()

void System::Condition::wait ( Mutex apMutex)

Waits on condition, until awakened by a signal or broadcast.

The current thread must own specified mutex.

Exceptions
SystemException
Note
The function shall block on a condition variable. It shall be called with mutex locked by the calling thread or undefined behavior results. Upon successful return, the mutex shall have been locked and shall be owned by the calling thread.