nidas  v1.2-1520
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) throw (Exception)
 Construct the guard object and lock() the lock. More...
 
 Autolock (Mutex &mutex) throw (Exception)
 Construct the guard object and lock() the lock. More...
 
 ~Autolock ()
 On destruction, unlock the lock. More...
 

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

nidas::util::Autolock::Autolock ( Cond cond)
throw (Exception
)
inline

Construct the guard object and lock() the lock.

nidas::util::Autolock::Autolock ( Mutex mutex)
throw (Exception
)
inline

Construct the guard object and lock() the lock.

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

On destruction, unlock the lock.

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

Member Function Documentation

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

Member Data Documentation

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

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