SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A guard class that acquires read access to its resource upon creation and releases it upon destruction. More...
#include <rw/sync/RWTReadLockGuard.h>
Public Member Functions | |
~RWTReadLockGuard () | |
RWTReadLockGuard (Resource &resource) | |
Private Member Functions | |
RWTReadLockGuard (const RWTReadLockGuard< Resource > &second) | |
RWTReadLockGuard< Resource > & | operator= (const RWTReadLockGuard< Resource > &second) |
RWTReadLockGuard<Resource> is a guard class that acquires read access on its resource upon creation and releases it upon destruction. Guard objects work in conjunction with block statements to 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 acquire read access on a mutex upon creation and release it when destructed. The class used as the template parameter 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/RWTReadLockGuard.h> // ... RWReadersWriterLock rwlock; void foo() { // acquire read access: RWTReadLockGuard<RWReaderWritersLock> lock(rwlock); // ... critical section // lock will be released in RWTReadLockGuard destructor // before leaving scope, especially important if an exception // might be thrown! }
RWTReadLockGuard< Resource >::~RWTReadLockGuard | ( | ) | [inline] |
Destructor.
RWTReadLockGuard< Resource >::RWTReadLockGuard | ( | Resource & | resource | ) | [inline] |
Constructs an instance with the given resource and acquires read access on that resource. The resource is released in the destructor of the base class.
RWTReadLockGuard< Resource >::RWTReadLockGuard | ( | const RWTReadLockGuard< Resource > & | second | ) | [private] |
Copy constructor prohibited.
RWTReadLockGuard<Resource>& RWTReadLockGuard< Resource >::operator= | ( | const RWTReadLockGuard< Resource > & | second | ) | [private] |
Assignment prohibited.
© 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.