Mutex_t Class Reference

Mutex class that avoids trips into the kernel until there's contention for the mutex.

#include <UTMutex.h>

List of all members.

Public Member Functions

 Mutex_t (bool allow_recursive_lock=false)
 ~Mutex_t ()
void Lock ()
void Unlock ()
thread_id_t LockedBy ()

Detailed Description

Definition at line 42 of file UTMutex.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

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]

Returns the ID of the thread which holds a lock on the mutex, if any. It should only be used to compare against the value returned by current_thread_id.

Definition at line 145 of file UTMutex.h.

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

Generated on Tue Dec 14 22:35:07 2010 for UT library by  doxygen 1.6.1