Panda3D
Public Member Functions | Friends | List of all members
MutexDirect Class Reference

This class implements a standard mutex by making direct calls to the underlying implementation layer. More...

#include "mutexDirect.h"

Inheritance diagram for MutexDirect:
Mutex

Public Member Functions

void acquire () const
 Grabs the mutex if it is available. More...
 
void clear_name ()
 The mutex name is only defined when compiling in DEBUG_THREADS mode. More...
 
bool debug_is_locked () const
 Returns true if the current thread has locked the Mutex, false otherwise. More...
 
std::string get_name () const
 The mutex name is only defined when compiling in DEBUG_THREADS mode. More...
 
bool has_name () const
 The mutex name is only defined when compiling in DEBUG_THREADS mode. More...
 
void lock ()
 Alias for acquire() to match C++11 semantics. More...
 
void output (std::ostream &out) const
 This method is declared virtual in MutexDebug, but non-virtual in MutexDirect. More...
 
void release () const
 Releases the mutex. More...
 
void set_name (const std::string &name)
 The mutex name is only defined when compiling in DEBUG_THREADS mode. More...
 
bool try_acquire () const
 Returns immediately, with a true value indicating the mutex has been acquired, and false indicating it has not. More...
 
bool try_lock ()
 Alias for try_acquire() to match C++11 semantics. More...
 
void unlock ()
 Alias for release() to match C++11 semantics. More...
 

Friends

class ConditionVarDirect
 
class ConditionVarFullDirect
 

Detailed Description

This class implements a standard mutex by making direct calls to the underlying implementation layer.

It doesn't perform any debugging operations.

Definition at line 30 of file mutexDirect.h.

Member Function Documentation

◆ acquire()

void MutexDirect::acquire ( ) const
inline

Grabs the mutex if it is available.

If it is not available, blocks until it becomes available, then grabs it. In either case, the function does not return until the mutex is held; you should then call unlock().

This method is considered const so that you can lock and unlock const mutexes, mainly to allow thread-safe access to otherwise const data.

Also see MutexHolder.

Definition at line 55 of file mutexDirect.I.

Referenced by MutexHolder::MutexHolder().

◆ clear_name()

void MutexDirect::clear_name ( )
inline

The mutex name is only defined when compiling in DEBUG_THREADS mode.

Definition at line 105 of file mutexDirect.I.

◆ debug_is_locked()

bool MutexDirect::debug_is_locked ( ) const
inline

Returns true if the current thread has locked the Mutex, false otherwise.

This method is only intended for use in debugging, hence the method name; in the MutexDirect case, it always returns true, since there's not a reliable way to determine this otherwise.

Definition at line 90 of file mutexDirect.I.

◆ get_name()

std::string MutexDirect::get_name ( ) const
inline

The mutex name is only defined when compiling in DEBUG_THREADS mode.

Definition at line 120 of file mutexDirect.I.

◆ has_name()

bool MutexDirect::has_name ( ) const
inline

The mutex name is only defined when compiling in DEBUG_THREADS mode.

Definition at line 112 of file mutexDirect.I.

◆ lock()

void MutexDirect::lock ( )
inline

Alias for acquire() to match C++11 semantics.

See also
acquire()

Definition at line 19 of file mutexDirect.I.

◆ output()

void MutexDirect::output ( std::ostream &  out) const

This method is declared virtual in MutexDebug, but non-virtual in MutexDirect.

Definition at line 23 of file mutexDirect.cxx.

◆ release()

void MutexDirect::release ( ) const
inline

Releases the mutex.

It is an error to call this if the mutex was not already locked.

This method is considered const so that you can lock and unlock const mutexes, mainly to allow thread-safe access to otherwise const data.

Definition at line 78 of file mutexDirect.I.

◆ set_name()

void MutexDirect::set_name ( const std::string &  name)
inline

The mutex name is only defined when compiling in DEBUG_THREADS mode.

Definition at line 98 of file mutexDirect.I.

◆ try_acquire()

bool MutexDirect::try_acquire ( ) const
inline

Returns immediately, with a true value indicating the mutex has been acquired, and false indicating it has not.

Definition at line 65 of file mutexDirect.I.

◆ try_lock()

bool MutexDirect::try_lock ( )
inline

Alias for try_acquire() to match C++11 semantics.

See also
try_acquire()

Definition at line 29 of file mutexDirect.I.

◆ unlock()

void MutexDirect::unlock ( )
inline

Alias for release() to match C++11 semantics.

See also
release()

Definition at line 39 of file mutexDirect.I.


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