org.eclipse.ecf.core.util
Class AsynchResult

java.lang.Object
  extended by org.eclipse.ecf.core.util.AsynchResult

public class AsynchResult
extends java.lang.Object

Class to represent asynchronous result (aka Future)


Field Summary
protected  java.lang.reflect.InvocationTargetException resultException
           
protected  boolean resultReady
           
protected  java.lang.Object resultValue
           
 
Constructor Summary
AsynchResult()
           
 
Method Summary
 void clear()
          Clear this AsynchResult.
protected  java.lang.Object doGet()
           
 java.lang.Object get()
          Get the underlying result.
 java.lang.Object get(long msecs)
          Get the underlying result with limited wait time.
 java.lang.reflect.InvocationTargetException getException()
          Get the InvocationTargetException that occured during invocation.
 boolean isReady()
           
 java.lang.Object peek()
           
 void set(java.lang.Object newValue)
          Set the result to a newValue.
 void setException(java.lang.Throwable ex)
          Set exception to ex
 java.lang.Runnable setter(ICallable function)
          Set the underlying function call that will return a result asynchronously
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resultValue

protected java.lang.Object resultValue

resultReady

protected boolean resultReady

resultException

protected java.lang.reflect.InvocationTargetException resultException
Constructor Detail

AsynchResult

public AsynchResult()
Method Detail

setter

public java.lang.Runnable setter(ICallable function)
Set the underlying function call that will return a result asynchronously

Parameters:
function - the ICallable to be called
Returns:
Runnable to run

doGet

protected java.lang.Object doGet()
                          throws java.lang.reflect.InvocationTargetException
Throws:
java.lang.reflect.InvocationTargetException

get

public java.lang.Object get()
                     throws java.lang.InterruptedException,
                            java.lang.reflect.InvocationTargetException
Get the underlying result. Block until result is available.

Returns:
Object that is result
Throws:
java.lang.InterruptedException - thrown if waiting is interrupted
java.lang.reflect.InvocationTargetException - thrown if exception was thrown by execution

get

public java.lang.Object get(long msecs)
                     throws TimeoutException,
                            java.lang.InterruptedException,
                            java.lang.reflect.InvocationTargetException
Get the underlying result with limited wait time. Behaves similarly to Object.wait(), but only waits msecs (ms) before throwing TimeoutException

Parameters:
msecs - to wait before timing out
Returns:
Object that is result
Throws:
TimeoutException - thrown if msecs elapse before a result is available
java.lang.InterruptedException - thrown if waiting is interrupted
java.lang.reflect.InvocationTargetException - thrown if exception was thrown by execution

set

public void set(java.lang.Object newValue)
Set the result to a newValue.

Parameters:
newValue - to set the result to

setException

public void setException(java.lang.Throwable ex)
Set exception to ex

Parameters:
ex - the Throwable to set the exception to

getException

public java.lang.reflect.InvocationTargetException getException()
Get the InvocationTargetException that occured during invocation. If null, no exception was thrown

Returns:
InvocationTargetException if an exception occurred (available via InvocationTargetException.getCause(). Null if no exception has occurred

isReady

public boolean isReady()
Returns:
true if result has been set or exception has occurred, false if not.

peek

public java.lang.Object peek()
Returns:
Object result that has been set or null if has not been set

clear

public void clear()
Clear this AsynchResult. Clears both the result Object and the InvocationTargetException (if set)