Mark3 Realtime Kernel
|
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 |
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.
void Mark3::ConditionVariable::Broadcast | ( | ) |
Broadcast Unblock all threads currently blocked on this condition variable.
Definition at line 77 of file condvar.cpp.
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.
|
inline |
void Mark3::ConditionVariable::Signal | ( | ) |
Signal Signal/Unblock the next thread currently blocked on this condition variable.
Definition at line 66 of file condvar.cpp.
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.
pclMutex_ | Mutex to claim once the calling thread has access to the condvar |
Definition at line 32 of file condvar.cpp.
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.
pclMutex_ | Mutex to claim once the calling thread has access to the condvar |
u32WaitTimeMS_ | Maximum time in ms to wait before abandoning the operation |
Definition at line 48 of file condvar.cpp.