SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTReadUnlockGuard< Resource > Class Template Reference

A guard class that releases its resource upon creation and acquires read access to its resource upon destruction. More...

#include <rw/sync/RWTReadUnlockGuard.h>

Inheritance diagram for RWTReadUnlockGuard< Resource >:
RWTReadGuardBase< Resource >

Public Member Functions

 RWTReadUnlockGuard (Resource &resource)
 
 ~RWTReadUnlockGuard (void)
 
- Public Member Functions inherited from RWTReadGuardBase< Resource >
 ~RWTReadGuardBase (void)
 
void acquire (void)
 
bool isAcquired (void) const
 
void release (void)
 

Private Member Functions

 RWTReadUnlockGuard (const RWTReadUnlockGuard< Resource > &second)
 
RWTReadUnlockGuard< Resource > & operator= (const RWTReadUnlockGuard< Resource > &second)
 

Additional Inherited Members

- Protected Member Functions inherited from RWTReadGuardBase< Resource >
 RWTReadGuardBase (Resource &resource)
 
 RWTReadGuardBase (Resource &resource, bool acquired)
 
Resource & resource (void) const
 

Detailed Description

template<class Resource>
class RWTReadUnlockGuard< Resource >

RWTReadUnlockGuard 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 template parameter Resource must be one that provides acquireRead() and release() methods, such as the synchronization classes provided in this module.

Example
#include <rw/sync/RWReadersWriterLock.h>
#include <rw/sync/RWTReadUnlockGuard.h>
// ...
void foo() {
rwlock.acquireRead();
// ... critical code
// temporarily release readers-writer lock
// for duration of block:
{
// constructor releases lock:
// ... anti-critical section
// lock will be reacquired for reading in
// RWTReadUnlockGuard destructor.
}
// ... more critical code
rwlock.release();
}
A synchronization lock that allows concurrent access to multiple readers, but limits access to a sing...
Definition RWReadersWriterLock.h:127
A guard class that releases its resource upon creation and acquires read access to its resource upon ...
Definition RWTReadUnlockGuard.h:70
See also
RWTReadLockGuard, RWTTryReadLockGuard

Constructor & Destructor Documentation

◆ RWTReadUnlockGuard() [1/2]

template<class Resource >
RWTReadUnlockGuard< Resource >::RWTReadUnlockGuard ( Resource & resource)
inline

Releases the resource.

◆ ~RWTReadUnlockGuard()

template<class Resource >
RWTReadUnlockGuard< Resource >::~RWTReadUnlockGuard ( void )
inline

Reacquires read access on the resource.

◆ RWTReadUnlockGuard() [2/2]

template<class Resource >
RWTReadUnlockGuard< Resource >::RWTReadUnlockGuard ( const RWTReadUnlockGuard< Resource > & second)
private

Copy construction prohibited.

Member Function Documentation

◆ operator=()

template<class Resource >
RWTReadUnlockGuard< Resource > & RWTReadUnlockGuard< Resource >::operator= ( const RWTReadUnlockGuard< Resource > & second)
private

Assignment prohibited.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.