RWTReadUnlockGuard<Resource> RWTReadGuardBase<Resource>
#include <rw/sync/RWTReadUnlockGuard.h>
RWTReadUnlockGuard<Resource> is a guard class that releases its resource upon creation and acquires read access to its resource upon destruction. Guard objects work in conjunction with block statements. The guard objects establish an appropriate state upon creation, maintain that state for the duration of the block, and restore the original state upon destruction. For example, a guard may release read access on a mutex upon creation and reacquire read access on that mutex when destructed. The class used as the actual template parameter for Resource must be one that provides acquireRead and release methods, such as the synchronization classes provided by the library.
#include <rw/sync/RWReadersWriterLock.h> #include <rw/sync/RWTReadUnlockGuard.h> // ... RWReadersWriterLock rwlock; void foo() { rwlock.acquireRead(); // ... critical code // temporarily release readers-writer lock
// for duration of block: { // constructor releases lock: RWTReadUnlockGuard<RWReadersWriterLock> lock(rwlock); // ... anti-critical section // lock will be reacquired for reading in // RWTReadUnlockGuard destructor. } // ... more critical code rwlock.release(); }
typedef Resource ResourceType;
RWTReadUnlockGuard(Resource& resource);
Releases the resource.
~RWTReadUnlockGuard(void);
Reacquires read access on the resource.
RWTReadUnlockGuard(const RWTReadUnlockGuard<Resource>& second);
Copy constructor is protected to disallow copy construction.
RWTReadUnlockGuard<Resource>& operator=(const RWTReadUnlockGuard<Resource>& second);
Assignment operator is protected to disallow assignment.
RWTReadLockGuard<Resource>, RWTTryReadLockGuard<Resource>
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.