Module: Threads Package: Synchronization
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 in this module.
#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();
Reacquires read access on the resource.
RWTReadUnlockGuard(const RWTReadUnlockGuard<Resource>& second);
Copy construction prohibited.
RWTReadUnlockGuard<Resource>& operator=(const RWTReadUnlockGuard<Resource>& second);
Assignment prohibited.
RWTReadLockGuard<Resource>, RWTTryReadLockGuard<Resource>
© 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.