Convenience class to synchronize access to a Monitor object. More...
#include <lock.h>
Public Member Functions | |
Lock (Monitor &m, const std::string &msg="") | |
Constructor. | |
~Lock () | |
Destructor. | |
Debugable * | debug_master () const |
Private Attributes | |
Monitor & | monitor_ |
Monitor on which lock is defined. | |
const std::string | msg_ |
Message to print on construction and destruction. |
Convenience class to synchronize access to a Monitor object.
Creating a lock enters the monitor, destroying the lock exits the monitor.
Example usage:
class SomeClassToProtect: public Dv::Thread::Monitor { public: voif f() { Lock lock(*this, "f", &cerr); // enter monitor access the object // destructor of lock will exit the monitor. } ... };
test-buffer.h, and test-pool.C.
Dv::Thread::Lock::Lock | ( | Monitor & | m, | |
const std::string & | msg = "" | |||
) |
Constructor.
This function will enter the monitor parameter.
m | monitor to enter. | |
msg | optional message to print to log |
Dv::Thread::Lock::~Lock | ( | ) |
Destructor.
This function will exit the monitor.
runtime_error | if the current thread is not in the monitor (e.g. if m.exit() was called before the destructor of the Lock). |
Debugable* Dv::Thread::Lock::debug_master | ( | ) | const [inline, virtual] |
Reimplemented from Dv::DebugSlave.
References monitor_.
Monitor& Dv::Thread::Lock::monitor_ [private] |
Monitor on which lock is defined.
Referenced by debug_master().
const std::string Dv::Thread::Lock::msg_ [private] |
Message to print on construction and destruction.
dvthread-0.13.4 | [11 December, 2009] |