nidas v1.2.3
|
Synchronized is used a simple guard object for critical sections. More...
#include <ThreadSupport.h>
Public Member Functions | |
Synchronized (Cond &cond_) | |
Construct the guard object and lock() the lock. | |
Synchronized (Mutex &mutex_) | |
~Synchronized () | |
On destruction, unlock the lock. | |
Private Member Functions | |
Synchronized (const Synchronized &) | |
Synchronized & | operator= (const Synchronized &) |
Private Attributes | |
Mutex * | mutexp |
Cond * | condp |
Synchronized 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.
|
inline |
Construct the guard object and lock() the lock.
As for Lock, be wary of recursively entering sections Synchronized on the same lock within the same thread. The default, posix mutexes are not recursive and so the thread will deadlock.
Exception |
References condp, and nidas::util::Cond::lock().
|
inline |
Exception |
References nidas::util::Mutex::lock(), and mutexp.
|
inline |
On destruction, unlock the lock.
References condp, mutexp, nidas::util::Mutex::unlock(), and nidas::util::Cond::unlock().
|
private |
|
private |
|
private |
Referenced by Synchronized(), and ~Synchronized().
|
private |
Referenced by Synchronized(), and ~Synchronized().