s11n::mutex_sentry Class Reference

This sentry class locks a mutex on construction and unlocks in on destruction. More...

#include <mutex.hpp>

List of all members.

Public Member Functions

 mutex_sentry (mutex &mx)
 Calls mx.lock().
 ~mutex_sentry () throw ()
 Unlocks the mutex we locked in the ctor.


Detailed Description

This sentry class locks a mutex on construction and unlocks in on destruction.

The intended usage is to instantiate it at the start of a routine which needs a lock. The instantiation will not return until the lock is acquired or the locking function throws an exception. Upon destruction of this object, the mutex will be unlocked.

Note that these objects are not copyable.

Definition at line 82 of file mutex.hpp.


Constructor & Destructor Documentation

s11n::mutex_sentry::mutex_sentry ( mutex mx  )  [explicit]

Calls mx.lock().

mx must outlive this object.

s11n::mutex_sentry::~mutex_sentry (  )  throw ()

Unlocks the mutex we locked in the ctor.


The documentation for this class was generated from the following file:
Generated on Wed Jun 4 21:44:20 2008 for libs11n by  doxygen 1.5.3