SourcePro® C++ API Reference Guide

Product Documentation:
   SourcePro C++
Documentation Home
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions
RWTGuardBase< T > Class Template Reference

Base class for guard classes. More...

#include <rw/sync/RWTGuardBase.h>

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

 RWTGuardBase (const RWTGuardBase< Resource > &second)
 
RWTGuardBaseoperator= (const RWTGuardBase< Resource > &second)
 

Detailed Description

template<class T>
class RWTGuardBase< T >

RWTGuardBase<Resource> is intended as a base class for guard classes. 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 when created and release it when destructed. The class used as the actual template parameter for Resource must be one that provides acquire() and release() methods, such as the synchronization classes in this module.

See Also
RWTLockGuardBase, RWTLockGuard, RWTTryLockGuard, RWTUnlockGuard

Constructor & Destructor Documentation

template<class T>
RWTGuardBase< T >::~RWTGuardBase ( )

Destructor.

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

Constructs an instance with the given resource.

template<class T>
RWTGuardBase< T >::RWTGuardBase ( Resource &  resource,
bool  acquired 
)
protected

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

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

Dummy copy constructor, required by derived class copy constructors. The copy constructor does not attempt to copy the resource.

Member Function Documentation

template<class T>
void RWTGuardBase< T >::acquire ( )

Acquires the resource held by the guard unless it has already been acquired. Use this function instead of directly manipulating the resource so that the guard will automatically release or acquire it (as appropriate).

template<class T>
bool RWTGuardBase< T >::isAcquired ( ) const

Returns true if the resource is currently acquired, otherwise false.

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

Assignment prohibited.

template<class T>
void RWTGuardBase< T >::release ( )

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

template<class T>
Resource& RWTGuardBase< T >::resource ( ) const
protected

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

Copyright © 2015 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.
Provide feedback to Rogue Wave about its documentation.