#include <lock.h>
Collaboration diagram for Dv::Thread::Lock:
Public Member Functions | |
Lock (Monitor &m, const std::string &msg="", std::ostream *log=0) | |
Constructor. | |
~Lock () throw (std::runtime_error) | |
Destructor. | |
Private Attributes | |
Monitor & | monitor_ |
Monitor on which lock is defined. | |
const std::string | msg_ |
Message to print on construction and destruction. | |
std::ostream * | log_ |
If non-zero, pointer to stream on which to log info. |
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. } ... };
The lock declaration can be abbreviated using the Java-inspired SYNCHRONIZED macro.
|
Constructor. This function will enter the monitor parameter.
|
|
Destructor. This function will exit the monitor.
|
|
Monitor on which lock is defined.
|
|
Message to print on construction and destruction.
|
|
If non-zero, pointer to stream on which to log info.
|
dvthread-0.5.0 | [22 June, 2006] |