Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Burger::ConditionVariable Class Reference

Class for creating a condition variable. More...

Public Member Functions

 ConditionVariable () noexcept
 Initialize a condition signaler.
 
 ~ConditionVariable ()
 Release the condition signaler's resources.
 
eError signal (void) noexcept
 Signal a waiting thread.
 
eError broadcast (void) noexcept
 Signal all waiting threads.
 
eError wait (Mutex *pMutex, uint32_t uMilliseconds=UINT32_MAX) noexcept
 Wait for a signal (With timeout)
 

Protected Attributes

uint64_t m_ConditionVariable [48/sizeof(uint64_t)]
 Condition variable instance.
 
uint_t m_bInitialized
 TRUE if the Condition variable instance successfully initialized
 

Private Member Functions

 ConditionVariable (const ConditionVariable &)=delete
 
ConditionVariableoperator= (const ConditionVariable &)=delete
 
 ConditionVariable (ConditionVariable &&)=delete
 
ConditionVariableoperator= (ConditionVariable &&)=delete
 

Detailed Description

Class for creating a condition variable.


In a multiprocessor system, it's sometimes necessary to have a thread wait until an external condition has been satisfied. Once this class is created, the consumer thread will call Wait() with a locked Mutex and a timeout and it will halt until time has expired or another thread sends a signal to this class to alert the waiting thread that the stars are finally right and great Cthulhu can rise again.

Further reading http://en.wikipedia.org/wiki/Condition_variable#Condition_variables

See also
Burger::Mutex, Burger::Semaphore and Burger::Thread

Constructor & Destructor Documentation

◆ ConditionVariable() [1/3]

Burger::ConditionVariable::ConditionVariable ( const ConditionVariable & )
privatedelete

◆ ConditionVariable() [2/3]

Burger::ConditionVariable::ConditionVariable ( ConditionVariable && )
privatedelete

◆ ConditionVariable() [3/3]

Burger::ConditionVariable::ConditionVariable ( )
noexcept

Initialize a condition signaler.


See also
~ConditionVariable()

◆ ~ConditionVariable()

Burger::ConditionVariable::~ConditionVariable ( )

Release the condition signaler's resources.


See also
ConditionVariable()

Member Function Documentation

◆ broadcast()

Burger::eError BURGER_API Burger::ConditionVariable::broadcast ( void )
noexcept

Signal all waiting threads.


If any threads are waiting for a signal, send a signal to all of them so they all may continue execution. If no thread is waiting, do nothing.

Returns
Zero on success, non-zero on error.
See also
signal() or wait(Mutex *,uint32_t)

◆ operator=() [1/2]

ConditionVariable & Burger::ConditionVariable::operator= ( ConditionVariable && )
privatedelete

◆ operator=() [2/2]

ConditionVariable & Burger::ConditionVariable::operator= ( const ConditionVariable & )
privatedelete

◆ signal()

Burger::eError BURGER_API Burger::ConditionVariable::signal ( void )
noexcept

Signal a waiting thread.


If a thread is waiting for a signal, send a signal to the thread so it may continue execution. If no thread is waiting, do nothing.

Returns
Zero on success, non-zero on error.
See also
broadcast() or wait(Mutex *,uint_t)

◆ wait()

Burger::eError BURGER_API Burger::ConditionVariable::wait ( Mutex * pMutex,
uint32_t uMilliseconds = UINT32_MAX )
noexcept

Wait for a signal (With timeout)


Halt the thread until a signal is received or if a timeout has elapsed. If any threads are waiting for a signal, send a signal to all of them so they all may continue execution. If no thread is waiting, do nothing.

Parameters
pMutexPointer to a Mutex to use with this object
uMillisecondsUINT32_MAX to wait forever, 0 for non-blocking
Returns
Zero on success, non-zero on error.
See also
signal() or broadcast()

Member Data Documentation

◆ m_bInitialized

uint_t Burger::ConditionVariable::m_bInitialized
protected

TRUE if the Condition variable instance successfully initialized

◆ m_ConditionVariable

uint64_t Burger::ConditionVariable::m_ConditionVariable[48/sizeof(uint64_t)]
protected

Condition variable instance.