Wefts::RMutex Class Reference
[Mutexes]

#include <wefts_rmutex.h>

Inheritance diagram for Wefts::RMutex:

Inheritance graph
[legend]
Collaboration diagram for Wefts::RMutex:

Collaboration graph
[legend]
List of all members.

Detailed Description

This is a reentrant mutex with spinlock.

This mutex ensures that a calling thread can lock and unlock the mutex an equal amount of times without being blocked. This allows to wrap functions that are doing a lock on a mutex around outer functions that must extend the lock in a wider area, or use the mutex in a recursive function.

Note:
All mutex classes are implemented via inline calls to maximize execution speed; also, their methods are extremely small.


Public Member Functions

 RMutex ()
 Initializes the internal data of the mutex.

virtual void lock ()
 Locks the mutex.

virtual bool trylock ()
 Tries to lock the mutex.

virtual void unlock ()
 Unlocks the mutex.


Private Attributes

OSThread m_owner
volatile int m_lockCount


Constructor & Destructor Documentation

Wefts::RMutex::RMutex  )  [inline]
 

Initializes the internal data of the mutex.


Member Function Documentation

virtual void Wefts::RMutex::lock  )  [inline, virtual]
 

Locks the mutex.

If the calling thread is already owning the lock, the function will return immediately. Anyhow, it is necessary to call the unlock() metod exactly the same amount of times that lock() has been called to ensure proper mutex releasing.

Reimplemented from Wefts::Mutex.

virtual bool Wefts::RMutex::trylock  )  [inline, virtual]
 

Tries to lock the mutex.

Tries to lock the mutex, and immediately returns.

If the mutex is free, the method locks it and returns true. If the mutex is locked by another thread, the method returns false.

If the mutex is already held by the current thread, the mutex lock count is rise, and the method returns true.

Returns:
true if successful false if unsuccessful.

Reimplemented from Wefts::Mutex.

virtual void Wefts::RMutex::unlock  )  [inline, virtual]
 

Unlocks the mutex.

Releases the lock held by the calling thread. If the calling thread is not the rightful owner of the lock, the request is ignored and the call returns immediately.

Reimplemented from Wefts::Mutex.


Member Data Documentation

volatile int Wefts::RMutex::m_lockCount [private]
 

OSThread Wefts::RMutex::m_owner [private]
 


The documentation for this class was generated from the following file:
Generated on Tue Oct 5 14:57:03 2004 for Wefts by doxygen 1.3.7