Panda3D
Public Member Functions | List of all members
ConditionVar Class Reference

A condition variable, usually used to communicate information about changing state to a thread that is waiting for something to happen. More...

#include "conditionVar.h"

Inheritance diagram for ConditionVar:
ConditionVarDirect

Public Member Functions

 ConditionVar (Mutex &mutex)
 You must pass in a Mutex to the condition variable constructor. More...
 
Mutexget_mutex () const
 Returns the mutex associated with this condition variable. More...
 
- Public Member Functions inherited from ConditionVarDirect
 ConditionVarDirect (MutexDirect &mutex)
 You must pass in a Mutex to the condition variable constructor. More...
 
MutexDirectget_mutex () const
 Returns the mutex associated with this condition variable. More...
 
void notify ()
 Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed. More...
 
void output (ostream &out) const
 This method is declared virtual in ConditionVarDebug, but non-virtual in ConditionVarDirect. More...
 
void wait ()
 Waits on the condition. More...
 
void wait (double timeout)
 Waits on the condition, with a timeout. More...
 

Detailed Description

A condition variable, usually used to communicate information about changing state to a thread that is waiting for something to happen.

A condition variable can be used to "wake up" a thread when some arbitrary condition has changed.

The ConditionVar class does not support the full semantics of POSIX condition variables. In particular, it does not support the broadcast or notify_all function. See ConditionVarFull for a more complete (but possibly more expensive) API.

A condition variable is associated with a single mutex, and several condition variables may share the same mutex.

This class inherits its implementation either from ConditionVarDebug or ConditionVarDirect, depending on the definition of DEBUG_THREADS.

Definition at line 47 of file conditionVar.h.

Constructor & Destructor Documentation

◆ ConditionVar()

ConditionVar::ConditionVar ( Mutex mutex)
inline

You must pass in a Mutex to the condition variable constructor.

This mutex may be shared by other condition variables, if desired. It is the caller's responsibility to ensure the Mutex object does not destruct during the lifetime of the condition variable.

Definition at line 27 of file conditionVar.I.

References ConditionVarDirect::ConditionVarDirect(), and get_mutex().

Member Function Documentation

◆ get_mutex()

Mutex & ConditionVar::get_mutex ( ) const
inline

Returns the mutex associated with this condition variable.

Definition at line 90 of file conditionVar.I.

References ConditionVarDirect::get_mutex().

Referenced by ConditionVar().


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