SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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)
 
void acquire (void)
 
bool isAcquired (void) const
 
void release (void)
 

Protected Member Functions

 RWTReadGuardBase (Resource &resource)
 
 RWTReadGuardBase (Resource &resource, bool acquired)
 
Resource & resource (void) 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

◆ ~RWTReadGuardBase()

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

Destructor.

◆ RWTReadGuardBase() [1/3]

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.

◆ RWTReadGuardBase() [2/3]

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.

◆ RWTReadGuardBase() [3/3]

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

Copy construction prohibited.

Member Function Documentation

◆ acquire()

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).

◆ isAcquired()

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

Returns true if the resource is currently acquired.

◆ operator=()

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

Assignment prohibited.

◆ release()

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).

◆ resource()

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

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

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