SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWTWriteUnlockGuard< 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/RWTWriteUnlockGuard.h>

Inheritance diagram for RWTWriteUnlockGuard< Resource >:
RWTWriteGuardBase< Resource >

Public Member Functions

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

Private Member Functions

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

Additional Inherited Members

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

Detailed Description

template<class Resource>
class RWTWriteUnlockGuard< Resource >

RWTWriteUnlockGuard is a guard class that releases its resource upon creation and acquires write access on its resource 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 release write access on a mutex when created and reacquire write access on that mutex when destructed.

The class used as the actual template parameter for Resource must provide acquireWrite() and release() methods such as the synchronization classes in this module.

Example
#include <rw/sync/RWReadersWriterLock.h>
#include <rw/sync/RWTWriteUnlockGuard.h>
// ...
void foo() {
rwlock.acquireWrite();
// ... critical code
// temporarily release readers-writer lock
// for duration of block:
{
// constructor releases lock:
// ... anti-critical section
// lock will be reacquired for writing in
// RWTWriteUnlockGuard 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 RWTWriteUnlockGuard.h:72
See also
RWTWriteLockGuard

Constructor & Destructor Documentation

◆ RWTWriteUnlockGuard() [1/2]

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

Releases the resource.

◆ ~RWTWriteUnlockGuard()

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

Reacquires write access on the resource.

◆ RWTWriteUnlockGuard() [2/2]

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

Copy construction prohibited.

Member Function Documentation

◆ operator=()

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

Assignment prohibited.

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