Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MynahSA::Lock Class Reference

#include <thread.hpp>

Collaboration diagram for MynahSA::Lock:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Lock (Mutex &m)
 constructor - requires a reference to a mutex object, blocks until mutex is acquired
 ~Lock ()
 destructor - releases the mutex

Detailed Description

Class Lock is a convienence class. It is created with a reference to a specific mutex, and that mutex is locked during Lock construction. E.g. Once you have created a lock, you hold the mutex. When a lock is destroyed (by means of the destructor) the mutex is freed.

The usage pattern for class Lock is a single function and/or frame in which the critical section behavior is contained. Consider: void f() { Lock l(myMutex); ... do shared stuff ... } The end of the frame releases the lock. This usage pattern can help prevent faults where locks are left in the acquired state.

Note: Class Lock is unavailable when MYNAHSA_USE_BOOST is set as a compile time option.

Definition at line 108 of file thread.hpp.


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