Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

SynchronizedBlock Class Reference

#include <coherence/lang/SynchronizedBlock.hpp>

List of all members.


Detailed Description

The SynchronizedBlock class allows for easy creation of synchronized code blocks based on an Object's monitor.

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

Author:
mf 2007.12.09

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 Objectm_cpObject
 Raw pointer to Object used to protect the synchronized block.
Object::View m_vObject
 Object used to protect the synchronized block.

Constructor & Destructor Documentation

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.


The documentation for this class was generated from the following file:
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.