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

CThreadRecursiveMutex Class Reference

#include <CThreadRecursiveMutex.h>

Inheritance diagram for CThreadRecursiveMutex:

CApplicationSerializer List of all members.

Public Member Functions

 CThreadRecursiveMutex ()
 Default Constructor.
 ~CThreadRecursiveMutex ()
 Destructor.
DAQThreadMutex getMutex () const
 < Retrieve m_Mutex
daqthread_t getOwningThread () const
 < Retrieve m_tOwningThread
unsigned getLockLevel () const
 < Retrieve m_LockLevel
DAQThreadMutex getMonitorMutex () const
 < Return m_MonitoMutex
int Lock ()
int UnLock ()
int TryLock ()
int isLocked ()
void UnLockCompletely ()

Protected Member Functions

void setMutex (const DAQThreadMutex am_Mutex)
void setOwningThread (const daqthread_t am_tOwningThread)
void setLockLevel (const unsigned am_nLockLevel)
void setMonitorMutex (const DAQThreadMutex am_MonitorMutex)

Private Member Functions

 CThreadRecursiveMutex (const CThreadRecursiveMutex &rRhs)
int operator== (const CThreadRecursiveMutex &aCThreadRecursiveMutex) const

Private Attributes

DAQThreadMutex m_Mutex
 Mutex locked.
daqthread_t m_tOwningThread
 Id of owning thread.
unsigned m_nLockLevel
 Locking depth for owning thread.
DAQThreadMutex m_MonitorMutex
 Atomicity Mutex.

Detailed Description

Provides a mutex which can be locked in a nested manner by a thread. The "nested ness' is managed through the m_nLockLevel and the m_OwningThread member. Atomicity of the otherwise non-atomic function is handled by bracketing calls with locks of the mutexe's own m_MonitorMutex Gaurentees:

Definition at line 320 of file CThreadRecursiveMutex.h.


Constructor & Destructor Documentation

CThreadRecursiveMutex::CThreadRecursiveMutex  ) 
 

Default Constructor.

Definition at line 314 of file CThreadRecursiveMutex.cpp.

CThreadRecursiveMutex::~CThreadRecursiveMutex  ) 
 

Destructor.

Definition at line 325 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex, m_Mutex, and m_nLockLevel.

CThreadRecursiveMutex::CThreadRecursiveMutex const CThreadRecursiveMutex rRhs  )  [private]
 

Copy construction is illegal and hence private and not implemented.


Member Function Documentation

unsigned CThreadRecursiveMutex::getLockLevel  )  const [inline]
 

< Retrieve m_LockLevel

Definition at line 359 of file CThreadRecursiveMutex.h.

Referenced by CEvent::Disable().

DAQThreadMutex CThreadRecursiveMutex::getMonitorMutex  )  const [inline]
 

< Return m_MonitoMutex

Definition at line 363 of file CThreadRecursiveMutex.h.

DAQThreadMutex CThreadRecursiveMutex::getMutex  )  const [inline]
 

< Retrieve m_Mutex

Definition at line 351 of file CThreadRecursiveMutex.h.

daqthread_t CThreadRecursiveMutex::getOwningThread  )  const [inline]
 

< Retrieve m_tOwningThread

Definition at line 355 of file CThreadRecursiveMutex.h.

Referenced by CEvent::Disable().

int CThreadRecursiveMutex::isLocked  ) 
 

Operation Type: Override.

Purpose:

Returns non zero if someone, anyone (even self()) owns the mutex. Note that the mutex is considered owned if the lock level is nonzero. This should even be faster than the base class implementation.

Definition at line 498 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex.

int CThreadRecursiveMutex::Lock  ) 
 

Operation Type: Override.

Purpose:

Locks the mutex. Returns zero on success, otherwise, errno has the reason for the failure. Note that if we own the mutex the lock level is incremented, otherwise, this function may block.

Definition at line 351 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex, m_Mutex, m_nLockLevel, and m_tOwningThread.

Referenced by CSocket::Connect(), CDAQTCLProcessor::DeleteRelay(), CEvent::Disable(), CEvent::Enable(), CDAQTCLProcessor::EvalRelay(), CTCPConnectionLost::Host(), CEvent::OnEvent(), CSocket::OpenSocket(), CXtEventLoop::operator()(), CTCPConnectionLost::Port(), CBufferEvent< T >::ProcessAddQueue(), CBufferEvent< T >::ProcessDelQueue(), CServerConnectionEvent::Protocol(), and CBufferEvent< U >::STD().

int CThreadRecursiveMutex::operator== const CThreadRecursiveMutex aCThreadRecursiveMutex  )  const [private]
 

Assignment is illegal and hence private and not implemented.

void CThreadRecursiveMutex::setLockLevel const unsigned  am_nLockLevel  )  [inline, protected]
 

Parameters:
am_nLockLevel  Set m_nLockLevel

Definition at line 378 of file CThreadRecursiveMutex.h.

void CThreadRecursiveMutex::setMonitorMutex const DAQThreadMutex  am_MonitorMutex  )  [inline, protected]
 

Parameters:
am_MonitorMutex  Set m_MonitorMutex

Definition at line 381 of file CThreadRecursiveMutex.h.

void CThreadRecursiveMutex::setMutex const DAQThreadMutex  am_Mutex  )  [inline, protected]
 

Parameters:
am_Mutex  Set m_Mutex

Definition at line 372 of file CThreadRecursiveMutex.h.

void CThreadRecursiveMutex::setOwningThread const daqthread_t  am_tOwningThread  )  [inline, protected]
 

Parameters:
am_tOwningThread  Set m_tOwningThread

Definition at line 375 of file CThreadRecursiveMutex.h.

int CThreadRecursiveMutex::TryLock  ) 
 

Operation Type: Override

Purpose:

Tries to lock the mutex. If the mutex is owned by the running thread the lock succeeds and the lock level is incremented. If the lock level is zero, then trylock is done on the base class and the result is returned. On success, the lock level is incremented. Returns 0 on success, otherwise, errno has reason for failure, if the lock was already held, errno == EAGAIN.

Definition at line 460 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex, m_Mutex, m_nLockLevel, and m_tOwningThread.

int CThreadRecursiveMutex::UnLock  ) 
 

Operation Type: Override

Purpose:

Unlocks a locked mutex. If the mutex is already locked by us, the lock level is decremented. The mutex is not actually released until the lock level goes to zero. If we don't own the mutex, and error results. Returns zero on success, otherwise, errno has the reason for the failure.

Bug:
Status returns from lock and unlock are not checked.

Definition at line 406 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex, m_Mutex, m_nLockLevel, and m_tOwningThread.

Referenced by CSocket::Connect(), CDAQTCLProcessor::DeleteRelay(), CEvent::Enable(), CDAQTCLProcessor::EvalRelay(), CTCPConnectionLost::Host(), CEvent::OnEvent(), CSocket::OpenSocket(), CXtEventLoop::operator()(), CTCPConnectionLost::Port(), CBufferEvent< T >::ProcessAddQueue(), CBufferEvent< T >::ProcessDelQueue(), CServerConnectionEvent::Protocol(), and CBufferEvent< U >::STD().

void CThreadRecursiveMutex::UnLockCompletely  ) 
 

Operation Type:

Purpose:

Releases all lock levels. If we don't already own the mutex, this call is a no-op, otherwise, the m_nLockLevel variable is set to zero and the underlying semaphore is unlocked.

Definition at line 521 of file CThreadRecursiveMutex.cpp.

References m_MonitorMutex, m_Mutex, m_nLockLevel, and m_tOwningThread.

Referenced by CEvent::Disable(), and CFileEvent::Exit().


Member Data Documentation

DAQThreadMutex CThreadRecursiveMutex::m_MonitorMutex [private]
 

Atomicity Mutex.

Definition at line 328 of file CThreadRecursiveMutex.h.

Referenced by isLocked(), Lock(), TryLock(), UnLock(), UnLockCompletely(), and ~CThreadRecursiveMutex().

DAQThreadMutex CThreadRecursiveMutex::m_Mutex [private]
 

Mutex locked.

Definition at line 325 of file CThreadRecursiveMutex.h.

Referenced by Lock(), TryLock(), UnLock(), UnLockCompletely(), and ~CThreadRecursiveMutex().

unsigned CThreadRecursiveMutex::m_nLockLevel [private]
 

Locking depth for owning thread.

Definition at line 327 of file CThreadRecursiveMutex.h.

Referenced by Lock(), TryLock(), UnLock(), UnLockCompletely(), and ~CThreadRecursiveMutex().

daqthread_t CThreadRecursiveMutex::m_tOwningThread [private]
 

Id of owning thread.

Definition at line 326 of file CThreadRecursiveMutex.h.

Referenced by Lock(), TryLock(), UnLock(), and UnLockCompletely().


The documentation for this class was generated from the following files:
Generated on Thu Jan 6 16:58:45 2005 for Spectrodaq External Event Framework by  doxygen 1.3.9.1