Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWTMonitor<Mutex>


Base Class

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Data Types

Member Functions

Package

Synchronization

Header File

#include <rw/sync/RWTMonitor.h> 

Description

Subclassing from RWTMonitor<Mutex> provides a convenient way to synchronize the member functions used to access the data or resources encapsulated by a class. RWTMonitor<Mutex> supplies the mutual exclusion and guard mechanisms for synchronizing member functions; any functions that must be synchronized use the supplied guard type to lock and unlock the monitor upon entry and exit from the function.

One advantage of using RWTMonitor<Mutex> as a base-class instead of directly inheriting from or including some synchronization class, is the monitor() member function. If you were to use your own mutex member for synchronization, you would have to cast away the const-ness of this in const member functions before acquiring or releasing the mutex. The monitor() function eliminates this inconvenience by always returning a non-const instance of the monitor. The reference returned by monitor() can be used to initialize any of public guard types defined by the RWTMonitor<Mutex> class.

Example

Public Typedef

typedef Mutex   MutexType;

Protected Typedefs

typedef RWTLockGuard< RWTMonitor< Mutex > >     LockGuard;
typedef RWTUnlockGuard< RWTMonitor< Mutex > >   UnlockGuard;
typedef RWTTryLockGuard< RWTMonitor< Mutex > >  TryLockGuard;

Protected Constructors

RWTMonitor(void);
RWTMonitor(RWStaticCtor);
RWTMonitor(const RWTMonitor<Mutex>& second);

Protected Member Operator

RWTMonitor<Mutex>&
operator=(const RWTMonitor<Mutex>&);

Protected Member Functions

void
acquire(void);
RWBoolean
isAcquired(void) const;

NOTE: This function is primarily intended for use in precondition assertions, and is only available when using the debug version of the library.
RWTMonitor<Mutex>&
monitor(void) const;
Mutex&
mutex(void);
void
release(void);
RWBoolean
tryAcquire(void):

See Also

RWMutexLock, RWTLockGuard<Resource>, RWTUnlockGuard<Resource>, RWTTryLockGuard<Resource>



Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.