Quick Links:

bal | bbl | bdl | bsl

Public Member Functions

bslmt::QLockGuard Class Reference

#include <bslmt_qlock.h>

List of all members.

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 Component bslmt_qlock


Constructor & Destructor Documentation

bslmt::QLockGuard::QLockGuard (  ) 

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

bslmt::QLockGuard::QLockGuard ( QLock qlock,
bool  doLock = true 
) [explicit]

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.

bslmt::QLockGuard::~QLockGuard (  ) 

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


Member Function Documentation

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

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

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.

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

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.

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.

void bslmt::QLockGuard::unlock (  ) 

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: