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

This class implements a condition variable; see ConditionVar for a brief introduction to this class. More...

#include "conditionVarFull.h"

Inheritance diagram for ConditionVarFull:
ConditionVarFullDirect

Public Member Functions

 ConditionVarFull (Mutex &mutex)
 You must pass in a Mutex to the condition variable constructor. More...
 
 ConditionVarFull (const ConditionVarFull &copy)=delete
 
Mutexget_mutex () const
 Returns the mutex associated with this condition variable. More...
 
ConditionVarFulloperator= (const ConditionVarFull &copy)=delete
 
- Public Member Functions inherited from ConditionVarFullDirect
 ConditionVarFullDirect (MutexDirect &mutex)
 You must pass in a Mutex to the condition variable constructor. More...
 
 ConditionVarFullDirect (const ConditionVarFullDirect &copy)=delete
 
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 notify_all ()
 Informs all of the other threads who are currently blocked on wait() that the relevant condition has changed. More...
 
ConditionVarFullDirectoperator= (const ConditionVarFullDirect &copy)=delete
 
void output (std::ostream &out) const
 This method is declared virtual in ConditionVarFullDebug, but non-virtual in ConditionVarFullDirect. More...
 
void wait ()
 Waits on the condition. More...
 
void wait (double timeout)
 Waits on the condition, with a timeout. More...
 

Detailed Description

This class implements a condition variable; see ConditionVar for a brief introduction to this class.

The ConditionVarFull class provides a more complete implementation than ConditionVar; in particular, it provides the notify_all() method, which is guaranteed to wake up all threads currently waiting on the condition (whereas notify() is guaranteed to wake up at least one thread, but may or may not wake up all of them).

This class exists because on certain platforms (e.g. Win32), implementing notify_all() requires more overhead, so you should use ConditionVar for cases when you do not require the notify_all() semantics.

There are still some minor semantics that POSIX condition variables provide which this implementation does not. For instance, it is required (not optional) that the caller of notify() or notify_all() is holding the condition variable's mutex before the call.

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

Definition at line 44 of file conditionVarFull.h.

Constructor & Destructor Documentation

◆ ConditionVarFull()

ConditionVarFull::ConditionVarFull ( Mutex mutex)
inlineexplicit

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 21 of file conditionVarFull.I.

Member Function Documentation

◆ get_mutex()

Mutex & ConditionVarFull::get_mutex ( ) const
inline

Returns the mutex associated with this condition variable.

Definition at line 34 of file conditionVarFull.I.

References ConditionVarFullDirect::get_mutex().


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