BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmt::QLockGuard Class Reference

#include <bslmt_qlock.h>

Public Member Functions

 QLockGuard ()
 
 QLockGuard (QLock *qlock, bool doLock=true)
 
 ~QLockGuard ()
 
void setQLock (QLock *qlock)
 
void lock ()
 
void lock (QLock *qlock)
 
int tryLock ()
 
void unlock ()
 

Detailed Description

This class provides the means to acquire and release the lock on a QLock object. Typically, the lock is acquired at construction and released automatically on destruction. This class also provides explicit lock, tryLock, and unlock primitives.

See bslmt_qlock

Constructor & Destructor Documentation

◆ QLockGuard() [1/2]

bslmt::QLockGuard::QLockGuard ( )
inline

Create a guard in the unlocked state, not associated with any QLock objects.

◆ QLockGuard() [2/2]

bslmt::QLockGuard::QLockGuard ( QLock qlock,
bool  doLock = true 
)
inlineexplicit

Create a guard associated with the specified qlock. Acquire the lock unless the (optionally) specified doLock is false. If the lock is not free, block until it can be acquired.

◆ ~QLockGuard()

bslmt::QLockGuard::~QLockGuard ( )
inline

Destroy this object. If this object holds a lock, automatically free it.

Member Function Documentation

◆ lock() [1/2]

void bslmt::QLockGuard::lock ( )

Acquire a lock on the associated QLock object. If the lock is not free, block until it can be acquired. The behavior is undefined if the calling thread already owns the lock on the QLock.

◆ lock() [2/2]

void bslmt::QLockGuard::lock ( QLock qlock)
inline

Associate this guard with the specified qlock and acquire the lock. If the lock is not free, block until it can be acquired. The behavior is undefined if the calling thread already owns the lock on qlock or if this object is in the locked state.

◆ setQLock()

void bslmt::QLockGuard::setQLock ( QLock qlock)
inline

Associate this guard with the specified qlock. The behavior is undefined if this object is already in a locked state.

◆ tryLock()

int bslmt::QLockGuard::tryLock ( )

Attempt to acquire a lock on the associated QLock object. Return 0 on success, a positive value of the associated QLock object is already locked, or a negative value if an error occurs.

◆ unlock()

void bslmt::QLockGuard::unlock ( )
inline

Release the lock on the associated QLock. The behavior is undefined unless this guard previously acquired the lock and has not already released it.


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