ahc.util
Class SynchronizedGetCode

java.lang.Object
  |
  +--ahc.util.SynchronizedGetCode

public abstract class SynchronizedGetCode
extends java.lang.Object

This class and performs a blocking wait on a lock and then retrieves an object.
The get operation first waits until a precondition is met and it can acquire a monitor, or until a timout is reached. The monitor is passed in to the constructor, and the precondition must be provided by implementing an abstract method.
If the precondition is met and the lock acquired, the actuel result is retrieved by calling the abstract hook "getUnsynchronized". This implementation retrieves the result without passing any parameters to the getUnsynchronized method.

Author:
Arno Haase

Constructor Summary
SynchronizedGetCode(java.lang.Object lock)
           
 
Method Summary
 java.lang.Object get(boolean blocking)
           
 java.lang.Object get(int timeoutMillis)
           
abstract  java.lang.Object getUnsynchronized()
           
abstract  boolean precondition()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedGetCode

public SynchronizedGetCode(java.lang.Object lock)
Method Detail

get

public java.lang.Object get(int timeoutMillis)
                     throws java.lang.InterruptedException,
                            TimeoutException
java.lang.InterruptedException
TimeoutException

get

public java.lang.Object get(boolean blocking)
                     throws java.lang.InterruptedException
java.lang.InterruptedException

precondition

public abstract boolean precondition()

getUnsynchronized

public abstract java.lang.Object getUnsynchronized()