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

A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a mutex. More...

#include "mutexHolder.h"

Public Member Functions

 MutexHolder (const Mutex &mutex)
 
 MutexHolder (const Mutex &mutex, Thread *current_thread)
 This variant on the constructor accepts the current thread as a parameter, if it is already known, as an optimization. More...
 
 MutexHolder (const MutexHolder &copy)=delete
 
 MutexHolder (Mutex *&mutex)
 If the MutexHolder constructor is given a pointer to a Mutex object (instead of an actual object), it will first check to see if the pointer is NULL, and allocate a new Mutex if it is. More...
 
MutexHolderoperator= (const MutexHolder &copy)=delete
 

Detailed Description

A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a mutex.

It is a C++ convenience wrapper to call release() automatically when a block exits (for instance, on return).

Definition at line 25 of file mutexHolder.h.

Constructor & Destructor Documentation

◆ MutexHolder() [1/2]

MutexHolder::MutexHolder ( const Mutex mutex,
Thread current_thread 
)
inline

This variant on the constructor accepts the current thread as a parameter, if it is already known, as an optimization.

Definition at line 29 of file mutexHolder.I.

◆ MutexHolder() [2/2]

MutexHolder::MutexHolder ( Mutex *&  mutex)
inline

If the MutexHolder constructor is given a pointer to a Mutex object (instead of an actual object), it will first check to see if the pointer is NULL, and allocate a new Mutex if it is.

This is intended as a convenience for functions that may need to reference a Mutex at static init time, when it is impossible to guarantee ordering of initializers.

Definition at line 47 of file mutexHolder.I.


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