BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls::BslLockGuard Class Reference

#include <bsls_bsllock.h>

Public Member Functions

 BslLockGuard (BslLock *lock)
 
 ~BslLockGuard ()
 
void release ()
 

Detailed Description

This class implements a guard for automatically acquiring and releasing the lock on an associated bsls::BslLock object. This mechanism follows the RAII idiom whereby the lock on the BslLock associated with a guard object is acquired upon construction and released upon destruction.

See bsls_bsllock

Constructor & Destructor Documentation

◆ BslLockGuard()

bsls::BslLockGuard::BslLockGuard ( BslLock lock)
inlineexplicit

Create a guard object that conditionally manages the specified lock, and acquires the lock on lock by invoking its lock method. The behavior is undefined unless the calling thread does not already hold the lock on lock. Note that deadlock may result if a guard is created for lock while the calling thread holds the lock on lock. Also note that lock must remain valid throughout the lifetime of this guard, or until release is called.

◆ ~BslLockGuard()

bsls::BslLockGuard::~BslLockGuard ( )
inline

Destroy this guard object and release the lock on the object it manages (if any) by invoking the unlock method of the object that was supplied at construction of this guard. If no lock is currently being managed, this method has no effect. Note that if this guard object currently manages a lock, this method assumes the behavior of BslLock::unlock.

Member Function Documentation

◆ release()

void bsls::BslLockGuard::release ( )
inline

Release from management, with no effect, the object currently managed by this guard, if any. Note that unlock is not called on the managed object upon its release.


The documentation for this class was generated from the following file: