Mutex class that avoids trips into the kernel until there's contention for the mutex.
#include <UTMutex.h>
Public Member Functions | |
Mutex_t (bool allow_recursive_lock=false) | |
~Mutex_t () | |
void | Lock () |
void | Unlock () |
thread_id_t | LockedBy () |
Definition at line 42 of file UTMutex.h.
Mutex_t::Mutex_t | ( | bool | allow_recursive_lock = false |
) |
Mutex constructor. If allow_recursive_lock is true, the same thread which holds the mutex can recursively acquire it.
Mutex_t::~Mutex_t | ( | ) |
Mutex destructor.
void Mutex_t::Lock | ( | ) |
Locks the mutex. Note that if the calling thread already holds the mutex, it cannot reacquire the mutex and an assertion failure will occur. While some mutex implementations allow a thread which holds the mutex to recursively acquire more lock references, that encourages sloppy synchronization design in general, which usually manifests itself in the form of deadlocks which are usually difficult to debug.
void Mutex_t::Unlock | ( | ) |
Unlocks the mutex.
thread_id_t Mutex_t::LockedBy | ( | ) | [inline] |