Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTRecursiveLock<Lock>

Module:  Threads   Package:  Synchronization


RWTRecursiveLock<Lock> RWSynchObject

Local Index

Members

Header File

#include <rw/sync/RWTRecursiveLock.h> 

Description

The RWMutexLock and RWFIFOMutexLock classes do not allow a thread to acquire the mutex if it already owns it. Attempts to do so will result in an assertion and abort in the debug version of the module, and may result in deadlock in the release version.

If you require recursive acquisition semantics for a mutex, you can use the RWTRecursiveLock<Lock> class to add this capability to an existing mutex class such as RWMutexLock or RWFIFOMutexLock.

This class allows the thread that owns a mutex to reacquire the mutex any number of times before ever releasing it. For each acquisition, however, the thread must release the mutex the same number of times before it will become available to another thread.

Example

Member Typedefs

typedef RWTLockGuard<RWTRecursiveLock<Mutex>> 
     LockGuard;
typedef RWTReadLockGuard<RWTRecursiveLock<Mutex>> 
     ReadLockGuard;
typedef RWTWriteLockGuard<RWTRecursiveLock<Mutex>>
     WriteLockGuard;
typedef RWTTryLockGuard<RWTRecursiveLock<Mutex>> 
     TryLockGuard;
typedef RWTTryReadLockGuard<RWTRecursiveLock<Mutex>>
     TryReadLockGuard;
typedef RWTTryWriteLockGuard<RWTRecursiveLock<Mutex>>
     TryWriteLockGuard;
typedef RWTUnlockGuard<RWTRecursiveLock<Mutex>> 
     UnlockGuard;
typedef RWTReadUnlockGuard<RWTRecursiveLock<Mutex>>
     ReadUnlockGuard;
typedef RWTWriteUnlockGuard<RWTRecursiveLock<Mutex>>
     WriteUnlockGuard;

Public Constructors

RWTRecursiveLock(RWCancellationState
state=RW_CANCELLATION_DISABLED);

Public Destructor

~RWTRecursiveLock();

Public Member Functions

void
acquire();
RWWaitStatus
acquire(unsigned long milliseconds);
void
acquireRead();
RWWaitStatus
acquireRead(unsigned long milliseconds);
void
acquireWrite();
RWWaitStatus
acquireWrite(unsigned long milliseconds);
bool
isAcquired() const;

NOTE -- Only available from the debug version of the module
void
release();
bool
tryAcquire();
bool
tryAcquireRead();
bool
tryAcquireWrite();

Private Constructor

RWTRecursiveLock(const RWTRecursiveLock<Lock>& second);

Private Member Operator

RWTRecursiveLock<Lock>&
operator=(const RWTRecursiveLock<Lock>& second);

See Also

RWMutexLock, RWFIFOMutexLock



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.