nidas v1.2.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::util::Autolock Class Reference

Autolock is used a simple guard object for critical sections. More...

#include <ThreadSupport.h>

Public Member Functions

 Autolock (Cond &cond)
 Construct the guard object and lock() the lock.
 
 Autolock (Mutex &mutex)
 Construct the guard object and lock() the lock.
 
 ~Autolock ()
 On destruction, unlock the lock.
 

Private Member Functions

 Autolock (const Autolock &)
 
Autolockoperator= (const Autolock &)
 

Private Attributes

Mutex_mutexp
 
Cond_condp
 

Detailed Description

Autolock is used a simple guard object for critical sections.

Upon construction it lock()s the given Lock, and then when it goes out of scope, either through a normal exit or an exception, it will be destroyed and the Lock will be unlock()ed. Inside the critical section the thread can call wait() on the Synchronized object to wait on the Lock condition.

Constructor & Destructor Documentation

◆ Autolock() [1/3]

nidas::util::Autolock::Autolock ( Cond & cond)
inline

Construct the guard object and lock() the lock.

Exceptions
Exception

References nidas::util::Cond::lock().

◆ Autolock() [2/3]

nidas::util::Autolock::Autolock ( Mutex & mutex)
inline

Construct the guard object and lock() the lock.

Exceptions
Exception

References nidas::util::Mutex::lock().

◆ ~Autolock()

nidas::util::Autolock::~Autolock ( )
inline

On destruction, unlock the lock.

References _condp, _mutexp, nidas::util::Mutex::unlock(), and nidas::util::Cond::unlock().

◆ Autolock() [3/3]

nidas::util::Autolock::Autolock ( const Autolock & )
private

Member Function Documentation

◆ operator=()

Autolock & nidas::util::Autolock::operator= ( const Autolock & )
private

Member Data Documentation

◆ _condp

Cond* nidas::util::Autolock::_condp
private

Referenced by ~Autolock().

◆ _mutexp

Mutex* nidas::util::Autolock::_mutexp
private

Referenced by ~Autolock().


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