Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

RecursiveMutex Class Reference

#include <RecursiveMutex.hpp>

Inheritance diagram for RecursiveMutex::

PThread_Mutex List of all members.

Public Methods

 RecursiveMutex ()
virtual ~RecursiveMutex ()

Protected Methods

virtual void lock ()
virtual void unlock ()
virtual void wait ()

Private Methods

 RecursiveMutex (const RecursiveMutex &src)
RecursiveMutex & operator= (const RecursiveMutex &right)

Private Attributes

unsigned int lockCount
pthread_t owner

Constructor & Destructor Documentation

RecursiveMutex::RecursiveMutex  
 

Definition at line 6 of file RecursiveMutex.cpp.

00006 : lockCount(0) { }

RecursiveMutex::~RecursiveMutex   [virtual]
 

Definition at line 8 of file RecursiveMutex.cpp.

00008 { }

RecursiveMutex::RecursiveMutex const RecursiveMutex &    src [private]
 


Member Function Documentation

void RecursiveMutex::lock   [protected, virtual]
 

Reimplemented from PThread_Mutex.

Definition at line 10 of file RecursiveMutex.cpp.

00010                           {
00011   if ( !lockCount || !pthread_equal( owner, pthread_self() ) ) {
00012     Mutex::lock();
00013     owner = pthread_self();
00014   }
00015 
00016   ++lockCount;
00017 }

RecursiveMutex& RecursiveMutex::operator= const RecursiveMutex &    right [private]
 

void RecursiveMutex::unlock   [protected, virtual]
 

Reimplemented from PThread_Mutex.

Definition at line 19 of file RecursiveMutex.cpp.

00019                             {
00020 
00021   if ( lockCount <= 0 ) {
00022     cout << "Mutex is already unlocked.\n";
00023     return;
00024   }
00025 
00026   if ( !pthread_equal(owner, pthread_self()) )
00027     cout << "Mutex is locked by another thread.\n";
00028     return;
00029   }

void RecursiveMutex::wait   [protected, virtual]
 

Definition at line 36 of file RecursiveMutex.cpp.

00036                           {
00037   unsigned int saveCount = lockCount;
00038   lockCount = 0;
00039   Mutex::wait();
00040   owner = pthread_self();
00041   lockCount = saveCount;
00042 }


Member Data Documentation

unsigned int RecursiveMutex::lockCount [private]
 

Definition at line 34 of file RecursiveMutex.hpp.

pthread_t RecursiveMutex::owner [private]
 

Reimplemented from PThread_Mutex.

Definition at line 35 of file RecursiveMutex.hpp.


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:49:34 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001