SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions
RWTReadGuardBase< Resource > Class Template Reference

Base class for guard classes that support read access to a given section of code. More...

#include <rw/sync/RWTReadGuardBase.h>

Inheritance diagram for RWTReadGuardBase< Resource >:
RWTReadLockGuardBase< Resource > RWTReadUnlockGuard< Resource > RWTReadLockGuard< Resource > RWTTryReadLockGuard< Resource >

Public Member Functions

 ~RWTReadGuardBase ()
 
void acquire ()
 
bool isAcquired () const
 
void release ()
 

Protected Member Functions

 RWTReadGuardBase (Resource &resource)
 
 RWTReadGuardBase (Resource &resource, bool acquired)
 
Resource & resource () const
 

Private Member Functions

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

Detailed Description

template<class Resource>
class RWTReadGuardBase< Resource >

RWTReadGuardBase is a base class for guard classes that support read access to a given section of code.

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 a mutex for reading 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.

See also
RWTReadLockGuardBase, RWTReadUnlockGuard

Constructor & Destructor Documentation

template<class Resource >
RWTReadGuardBase< Resource >::~RWTReadGuardBase ( )

Destructor.

template<class Resource >
RWTReadGuardBase< Resource >::RWTReadGuardBase ( Resource &  resource)
inlineprotected
Deprecated:
As of SourcePro 13, use RWTReadGuardBase(Resource&, bool) instead.

Constructs an instance with the given resource.

template<class Resource >
RWTReadGuardBase< Resource >::RWTReadGuardBase ( Resource &  resource,
bool  acquired 
)
inlineprotected

Constructs an instance with the given resource. If acquired is true, the resource is assumed to be owned by the caller.

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

Copy construction prohibited.

Member Function Documentation

template<class Resource >
void RWTReadGuardBase< Resource >::acquire ( void  )
inline

Acquires read access on the resource held by the guard unless access has already been acquired. Use this function rather than manipulating the resource directly so the guard will automatically release or acquire access (as appropriate).

template<class Resource >
bool RWTReadGuardBase< Resource >::isAcquired ( ) const
inline

Returns true if the resource is currently acquired.

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

Assignment prohibited.

template<class Resource >
void RWTReadGuardBase< Resource >::release ( void  )
inline

Releases the resource held by the guard if it has been acquired. Use this function rather than manipulating the resource directly so the guard will automatically release or acquire access (as appropriate).

template<class Resource >
Resource & RWTReadGuardBase< Resource >::resource ( ) const
inlineprotected

Returns a reference to the resource currently held by the guard.

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