SourcePro® API Reference Guide

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

Base class for guard classes that acquire their resource upon creation and release it upon destruction. More...

#include <rw/sync/RWTLockGuardBase.h>

Inheritance diagram for RWTLockGuardBase< Resource >:
RWTGuardBase< Resource > RWTLockGuard< Resource > RWTTryLockGuard< Resource >

Public Member Functions

 ~RWTLockGuardBase (void)
 
- Public Member Functions inherited from RWTGuardBase< Resource >
 ~RWTGuardBase (void)
 
void acquire (void)
 
bool isAcquired (void) const
 
void release (void)
 

Protected Member Functions

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

Private Member Functions

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

Detailed Description

template<class Resource>
class RWTLockGuardBase< Resource >

RWTLockGuardBase is a base class for guard classes that acquire their resource upon creation and 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 a mutex upon creation 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 of the Threads Module.

See also
RWTLockGuard, RWTTryLockGuard, RWTUnlockGuard

Constructor & Destructor Documentation

◆ ~RWTLockGuardBase()

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

Releases the resource if it has been acquired.

◆ RWTLockGuardBase() [1/3]

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

Constructs a guard instance with the given resource. Note that this constructor does not attempt to acquire the resource. That is the responsibility of the derived class.

◆ RWTLockGuardBase() [2/3]

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

Constructs a guard instance with the given resource. If acquired is true, the resource is assumed to be owned by the caller. Note that this constructor does not attempt to acquire the resource. That is the responsibility of the derived class.

◆ RWTLockGuardBase() [3/3]

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

Copy constructor prohibited.

Member Function Documentation

◆ operator=()

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

Assignment prohibited.

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