com.koushikdutta.async.future
Class SimpleFuture<T>

java.lang.Object
  extended by com.koushikdutta.async.future.SimpleCancellable
      extended by com.koushikdutta.async.future.SimpleFuture<T>
All Implemented Interfaces:
Cancellable, DependentCancellable, DependentFuture<T>, java.util.concurrent.Future<T>
Direct Known Subclasses:
TransformFuture

public class SimpleFuture<T>
extends SimpleCancellable
implements DependentFuture<T>


Field Summary
 
Fields inherited from class com.koushikdutta.async.future.SimpleCancellable
COMPLETED
 
Constructor Summary
SimpleFuture()
           
 
Method Summary
 boolean cancel()
          Attempt to cancel this asynchronous operation.
 boolean cancel(boolean mayInterruptIfRunning)
           
 T get()
           
 T get(long timeout, java.util.concurrent.TimeUnit unit)
           
 FutureCallback<T> getCompletionCallback()
           
 SimpleFuture<T> setCallback(FutureCallback<T> callback)
          Set a callback to be invoked when this Future completes.
 boolean setComplete()
           
 boolean setComplete(java.lang.Exception e)
           
 boolean setComplete(java.lang.Exception e, T value)
           
 boolean setComplete(T value)
           
 SimpleFuture<T> setParent(Cancellable parent)
           
 
Methods inherited from class com.koushikdutta.async.future.SimpleCancellable
cancelCleanup, cleanup, completeCleanup, isCancelled, isDone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.Future
isCancelled, isDone
 
Methods inherited from interface com.koushikdutta.async.future.Cancellable
isCancelled, isDone
 

Constructor Detail

SimpleFuture

public SimpleFuture()
Method Detail

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Specified by:
cancel in interface java.util.concurrent.Future<T>

cancel

public boolean cancel()
Description copied from interface: Cancellable
Attempt to cancel this asynchronous operation.

Specified by:
cancel in interface Cancellable
Overrides:
cancel in class SimpleCancellable
Returns:
The return value is whether the operation cancelled successfully.

get

public T get()
      throws java.lang.InterruptedException,
             java.util.concurrent.ExecutionException
Specified by:
get in interface java.util.concurrent.Future<T>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

get

public T get(long timeout,
             java.util.concurrent.TimeUnit unit)
      throws java.lang.InterruptedException,
             java.util.concurrent.ExecutionException,
             java.util.concurrent.TimeoutException
Specified by:
get in interface java.util.concurrent.Future<T>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException

setComplete

public boolean setComplete()
Overrides:
setComplete in class SimpleCancellable

setComplete

public boolean setComplete(java.lang.Exception e)

setComplete

public boolean setComplete(T value)

setComplete

public boolean setComplete(java.lang.Exception e,
                           T value)

getCompletionCallback

public FutureCallback<T> getCompletionCallback()

setCallback

public SimpleFuture<T> setCallback(FutureCallback<T> callback)
Description copied from interface: Future
Set a callback to be invoked when this Future completes.

Returns:

setParent

public SimpleFuture<T> setParent(Cancellable parent)
Specified by:
setParent in interface DependentCancellable
Overrides:
setParent in class SimpleCancellable