Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::ConditionVariable Class Reference

Core class that represents a condition variable. More...

Public Member Functions

 ConditionVariable ()
 Constructs a ConditionVariable object by default.
 
 ConditionVariable (const ConditionVariable &)=delete
 
 ConditionVariable (ConditionVariable &&condition) noexcept=default
 
 ~ConditionVariable ()
 Destructs the object.
 
void Signal ()
 Sends a signal to one thread waiting on the condition. More...
 
void SignalAll ()
 Sends a signal to every threads waiting on the condition. More...
 
void Wait (Mutex *mutex)
 Makes the thread wait on the condition. More...
 
bool Wait (Mutex *mutex, UInt32 timeout)
 Makes the thread wait on the condition for a certain amount of time. More...
 
ConditionVariableoperator= (const ConditionVariable &)=delete
 
ConditionVariableoperator= (ConditionVariable &&condition) noexcept=default
 

Detailed Description

Core class that represents a condition variable.

The ConditionVariable class is a synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the ConditionVariable

Member Function Documentation

◆ Signal()

void Nz::ConditionVariable::Signal ( )

Sends a signal to one thread waiting on the condition.

If any threads are waiting on *this, calling Signal unblocks one of the waiting threads

See also
SignalAll

◆ SignalAll()

void Nz::ConditionVariable::SignalAll ( )

Sends a signal to every threads waiting on the condition.

Unblocks all threads currently waiting for *this

See also
Signal

◆ Wait() [1/2]

void Nz::ConditionVariable::Wait ( Mutex mutex)

Makes the thread wait on the condition.

Wait causes the current thread to block until the condition variable is notified or a spurious wakeup occurs

Parameters
mutexMutex for the condition
Remarks
Produces a NazaraAssert if mutex is invalid

◆ Wait() [2/2]

bool Nz::ConditionVariable::Wait ( Mutex mutex,
UInt32  timeout 
)

Makes the thread wait on the condition for a certain amount of time.

Wait causes the current thread to block until the condition variable is notified, a specific time is reached, or a spurious wakeup occurs

Parameters
mutexMutex for the condition
timeoutTime before expiration of the waiting
Remarks
Produces a NazaraAssert if mutex is invalid

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