Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

RecursiveMutex Class Reference

This class implements a recursive mutex (mutual exclusion device). More...

#include <mutex.h>

Collaboration diagram for RecursiveMutex:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RecursiveMutex ()
 Create a recursive mutex.

 ~RecursiveMutex ()
void lock ()
 Lock the mutex.

bool test ()
 Try to lock the mutex: Non-blocking variant of lock().

void unlock ()
 Unlock the mutex.


Private Attributes

GStaticRecMutex m

Detailed Description

This class implements a recursive mutex (mutual exclusion device).

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [

Definition at line 129 of file mutex.h.


Constructor & Destructor Documentation

RecursiveMutex::RecursiveMutex  ) 
 

Create a recursive mutex.

Definition at line 34 of file mutex.cc.

References m.

RecursiveMutex::~RecursiveMutex  )  [inline]
 

Destroy a mutex. Make sure that the mutex is unlocked before destroying it.

Definition at line 143 of file mutex.h.

References m, and USE_PRIVATE__PTHREADS.


Member Function Documentation

void RecursiveMutex::lock  )  [inline]
 

Lock the mutex.

If the mutex is currently unlocked, it becomes locked and owned by the calling thread, and the function returns immediately. If the mutex is already locked by another thread, this function suspends the calling thread until the mutex is unlocked. If the mutex is already locked by the calling thread, the call succeeds and returns immediately, recording the number of times the calling thread has locked the mutex. An equal number of unlock() operations must be performed before the mutex returns to the unlocked state.

Definition at line 163 of file mutex.h.

References m, and USE_PRIVATE__PTHREADS.

Referenced by ModulePool::_FindObjectByName(), ModulePool::_load(), ThreadKernel::_NRunningThreads(), ThreadKernel::_PhookNotifier(), MessageManager::_PostMessage(), MessageManager::_RegisterHandler(), MessageManager::_SelectMessageTypes(), ThreadKernel::_ThreadFuncWrapper(), ThreadKernel::_unregister(), ModulePool::_unregister(), MessageManager::_UnregisterHandler(), ThreadKernel::ThreadKernel(), MessageManager::~MessageManager(), ModulePool::~ModulePool(), and ThreadKernel::~ThreadKernel().

bool RecursiveMutex::test  )  [inline]
 

Try to lock the mutex: Non-blocking variant of lock().

Returns:
Returns 0 if the mutex is busy, otherwise lock mutex and return 1.

Definition at line 175 of file mutex.h.

References m, and USE_PRIVATE__PTHREADS.

void RecursiveMutex::unlock  )  [inline]
 

Unlock the mutex.

The mutex is assumed to be locked and owned by the calling thread on entrance to this function. The function decrements the locking count of the mutex (number of lock() operations performed on it), and only when this count reaches zero is the mutex actually unlocked.

Definition at line 190 of file mutex.h.

References m, and USE_PRIVATE__PTHREADS.

Referenced by ModulePool::_FindObjectByName(), ModulePool::_load(), ThreadKernel::_NRunningThreads(), ThreadKernel::_PhookNotifier(), MessageManager::_PostMessage(), MessageManager::_RegisterHandler(), MessageManager::_SelectMessageTypes(), ThreadKernel::_ThreadFuncWrapper(), ThreadKernel::_unregister(), ModulePool::_unregister(), MessageManager::_UnregisterHandler(), ThreadKernel::ThreadKernel(), MessageManager::~MessageManager(), ModulePool::~ModulePool(), and ThreadKernel::~ThreadKernel().


Member Data Documentation

GStaticRecMutex RecursiveMutex::m [private]
 

Definition at line 135 of file mutex.h.

Referenced by lock(), RecursiveMutex(), test(), unlock(), and ~RecursiveMutex().


The documentation for this class was generated from the following files:
Generated on Sat Feb 19 22:35:35 2005 for Ray by doxygen 1.3.5