ix.util
Class FutureValue

java.lang.Object
  extended by ix.util.FutureValue
Direct Known Subclasses:
SecureRandomTest.FutureRandom

public abstract class FutureValue
extends java.lang.Object

Computes a value in a separate thread. Example:

   FutureValue fv = new FutureValue("computes v") {
       public Object computeValue() {
           ...;
       }
   };
   fv.start();
   ...
   Object v = fv.getValue();
 
getValue() waits until the value is available.


Constructor Summary
FutureValue(java.lang.String name)
          Construct a FutureValue that has a daemon thread for computing the value.
 
Method Summary
abstract  java.lang.Object computeValue()
           
 java.lang.Object getValue()
          Returns the computed value once it is available.
 boolean isReady()
           
 void start()
          Start the thread that will compute the value.
 void waitUntilReady(long timeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FutureValue

public FutureValue(java.lang.String name)
Construct a FutureValue that has a daemon thread for computing the value. This is normally called for a subclass that defines the computeValue() method.

Method Detail

start

public void start()
Start the thread that will compute the value.


getValue

public java.lang.Object getValue()
Returns the computed value once it is available.

Throws:
RethrownException - if the computation of the value threw and error or exception.

waitUntilReady

public void waitUntilReady(long timeout)

isReady

public boolean isReady()

computeValue

public abstract java.lang.Object computeValue()