#include <coherence/lang/SynchronizedBlock.hpp>
The SynchronizedBlock object will ensure that the monitor is entered and exited as part of starting and ending the code block.
Example usage:
// outside of sync block { SynchronizedBlock sync(vObject); // monitor entered // critical section goes here // ... } // monitor exited // outside of sync block
A more friendly form is to use the COH_SYNCHRONIZED macro. Example usage:
// outside of sync block COH_SYNCHRONIZED(vLock) // monitor entered { // critical section goes here // ... // ... } // monitor exited // outside of sync block
Public Member Functions | |
SynchronizedBlock (Object::View v) | |
Construct a SynchronizedBlock object. | |
SynchronizedBlock (const Object *p) | |
Construct a SynchronizedBlock object from a raw object pointer. | |
SynchronizedBlock (const SynchronizedBlock &that) | |
Copy constructor for COH_SYNCHRONIZED macro. | |
~SynchronizedBlock () | |
Destroy a SynchronizedBlock object. | |
Protected Attributes | |
const Object * | m_cpObject |
Raw pointer to Object used to protect the synchronized block. | |
Object::View | m_vObject |
Object used to protect the synchronized block. |
SynchronizedBlock | ( | Object::View | v | ) | [inline] |
Construct a SynchronizedBlock object.
This will automatically enter the monitor.
SynchronizedBlock | ( | const Object * | p | ) | [inline] |
Construct a SynchronizedBlock object from a raw object pointer.
This will automatically enter the monitor.
The caller must ensure that the referenced Object is kept alive for the lifetime of the SynchronizedBlock. This method is generally used for synchronizing on "this", which implicitly ensures the lifetime guarantee.
~SynchronizedBlock | ( | ) | [inline] |
Destroy a SynchronizedBlock object.
This will automatically exit the monitor.