Panda3D
Public Member Functions | Friends

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

List of all members.

Public Member Functions

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

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 32 of file mutexDirect.h.


Member Function Documentation

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 70 of file mutexDirect.I.

Referenced by AsyncTaskManager::add(), AsyncTaskChain::cleanup_task(), AsyncTaskChain::do_cleanup(), AsyncTaskChain::do_stop_threads(), MutexHolder::MutexHolder(), AsyncTaskManager::remove(), AsyncTask::unlock_and_do_task(), and Texture::unlocked_ensure_ram_image().

void MutexDirect::clear_name ( ) [inline]

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

Definition at line 136 of file mutexDirect.I.

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 115 of file mutexDirect.I.

string MutexDirect::get_name ( ) const [inline]

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

Definition at line 157 of file mutexDirect.I.

bool MutexDirect::has_name ( ) const [inline]

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

Definition at line 146 of file mutexDirect.I.

void MutexDirect::output ( ostream &  out) const

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

Definition at line 26 of file mutexDirect.cxx.

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 99 of file mutexDirect.I.

Referenced by AsyncTaskManager::add(), AsyncTaskChain::cleanup_task(), AsyncTaskChain::do_cleanup(), AsyncTaskChain::do_stop_threads(), AsyncTaskManager::remove(), AsyncTask::unlock_and_do_task(), and Texture::unlocked_ensure_ram_image().

void MutexDirect::set_name ( const string &  name) [inline]

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

Definition at line 126 of file mutexDirect.I.

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 83 of file mutexDirect.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations