This class implements a standard mutex by making direct calls to the underlying implementation layer. More...
#include "mutexDirect.h"
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 |
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.
|
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().
|
inline |
The mutex name is only defined when compiling in DEBUG_THREADS mode.
Definition at line 105 of file mutexDirect.I.
|
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.
|
inline |
The mutex name is only defined when compiling in DEBUG_THREADS mode.
Definition at line 120 of file mutexDirect.I.
|
inline |
The mutex name is only defined when compiling in DEBUG_THREADS mode.
Definition at line 112 of file mutexDirect.I.
|
inline |
Alias for acquire() to match C++11 semantics.
Definition at line 19 of file mutexDirect.I.
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.
|
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.
|
inline |
The mutex name is only defined when compiling in DEBUG_THREADS mode.
Definition at line 98 of file mutexDirect.I.
|
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.
|
inline |
Alias for try_acquire() to match C++11 semantics.
Definition at line 29 of file mutexDirect.I.
|
inline |
Alias for release() to match C++11 semantics.
Definition at line 39 of file mutexDirect.I.