Mark3 Realtime Kernel
Mark3::ConditionVariable Class Reference

The ConditionVariable class This class implements a condition variable. This is a synchronization object that allows multiple threads to block, each waiting for specific signals unique to them. Access to the specified condition is guarded by a mutex that is supplied by the caller. This object can permit multiple waiters that can be unblocked one-at-a-time via signalling, or unblocked all at once via broadcasting. This object is built upon lower-level primatives, and is somewhat more heavyweight than the primative types supplied by the kernel. More...

#include <condvar.h>

Public Member Functions

void * operator new (size_t sz, void *pv)
 
void Init ()
 Init Initialize the condition variable prior to use. Must be called before the object can be used. More...
 
void Wait (Mutex *pclMutex_)
 Wait Block the current thread, and wait for the object to be signalled. The specified mutex will be locked when the thread returns. More...
 
bool Wait (Mutex *pclMutex_, uint32_t u32WaitTimeMS_)
 Wait Block the current thread, and wait for the object to be signalled. The specified mutex will be locked when the thread returns. More...
 
void Signal ()
 Signal Signal/Unblock the next thread currently blocked on this condition variable. More...
 
void Broadcast ()
 Broadcast Unblock all threads currently blocked on this condition variable. More...
 

Private Attributes

Mutex m_clMutex
 
Semaphore m_clSemaphore
 
uint8_t m_u8Waiters
 

Detailed Description

The ConditionVariable class This class implements a condition variable. This is a synchronization object that allows multiple threads to block, each waiting for specific signals unique to them. Access to the specified condition is guarded by a mutex that is supplied by the caller. This object can permit multiple waiters that can be unblocked one-at-a-time via signalling, or unblocked all at once via broadcasting. This object is built upon lower-level primatives, and is somewhat more heavyweight than the primative types supplied by the kernel.

Definition at line 39 of file condvar.h.

Member Function Documentation

◆ Broadcast()

void Mark3::ConditionVariable::Broadcast ( )

Broadcast Unblock all threads currently blocked on this condition variable.

Definition at line 77 of file condvar.cpp.

◆ Init()

void Mark3::ConditionVariable::Init ( void  )

Init Initialize the condition variable prior to use. Must be called before the object can be used.

Definition at line 25 of file condvar.cpp.

◆ operator new()

void* Mark3::ConditionVariable::operator new ( size_t  sz,
void *  pv 
)
inline

Definition at line 42 of file condvar.h.

◆ Signal()

void Mark3::ConditionVariable::Signal ( )

Signal Signal/Unblock the next thread currently blocked on this condition variable.

Definition at line 66 of file condvar.cpp.

◆ Wait() [1/2]

void Mark3::ConditionVariable::Wait ( Mutex pclMutex_)

Wait Block the current thread, and wait for the object to be signalled. The specified mutex will be locked when the thread returns.

Parameters
pclMutex_Mutex to claim once the calling thread has access to the condvar

Definition at line 32 of file condvar.cpp.

◆ Wait() [2/2]

bool Mark3::ConditionVariable::Wait ( Mutex pclMutex_,
uint32_t  u32WaitTimeMS_ 
)

Wait Block the current thread, and wait for the object to be signalled. The specified mutex will be locked when the thread returns.

Parameters
pclMutex_Mutex to claim once the calling thread has access to the condvar
u32WaitTimeMS_Maximum time in ms to wait before abandoning the operation
Returns
true on success, false on timeout

Definition at line 48 of file condvar.cpp.

Member Data Documentation

◆ m_clMutex

Mutex Mark3::ConditionVariable::m_clMutex
private

Definition at line 82 of file condvar.h.

◆ m_clSemaphore

Semaphore Mark3::ConditionVariable::m_clSemaphore
private

Definition at line 83 of file condvar.h.

◆ m_u8Waiters

uint8_t Mark3::ConditionVariable::m_u8Waiters
private

Definition at line 84 of file condvar.h.


The documentation for this class was generated from the following files: