Guard class that tries to acquire read access on its resource upon creation and release it upon destruction.
More...
template<class Resource>
class RWTTryReadLockGuard< Resource >
RWTTryReadLockGuard is a guard class that tries to acquire read access on its resource upon creation and, if successful, release 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 when created and release it when destructed. The class used as the actual template parameter for Resource
must be one that provides tryAcquireRead
() and release
() methods, such as some synchronization classes provided in this module.
- Example
#include <rw/sync/RWReadersWriterLock.h>
#include <rw/sync/RWTTryReadLockGuard.h>
bool foo() {
{
if (!lock.isAcquired()) {
return false;
}
}
return true;
}
A synchronization lock that allows concurrent access to multiple readers, but limits access to a sing...
Definition RWReadersWriterLock.h:127
Guard class that tries to acquire read access on its resource upon creation and release it upon destr...
Definition RWTTryReadLockGuard.h:73
- See also
- RWTReadLockGuard