T - the future result type of an asynchronous operation.public class BasicFuture<T> extends java.lang.Object implements java.util.concurrent.Future<T>, Cancellable
Future interface. BasicFuture
can be put into a completed state by invoking any of the following methods:
cancel(), failed(Exception), or completed(Object).| Modifier and Type | Field and Description |
|---|---|
private FutureCallback<T> |
callback |
private boolean |
cancelled |
private boolean |
completed |
private java.lang.Exception |
ex |
private T |
result |
| Constructor and Description |
|---|
BasicFuture(FutureCallback<T> callback) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel() |
boolean |
cancel(boolean mayInterruptIfRunning) |
boolean |
completed(T result) |
boolean |
failed(java.lang.Exception exception) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
private T |
getResult() |
boolean |
isCancelled() |
boolean |
isDone() |
private final FutureCallback<T> callback
private volatile boolean completed
private volatile boolean cancelled
private volatile T result
private volatile java.lang.Exception ex
public BasicFuture(FutureCallback<T> callback)
public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<T>public boolean isDone()
isDone in interface java.util.concurrent.Future<T>private T getResult() throws java.util.concurrent.ExecutionException
java.util.concurrent.ExecutionExceptionpublic T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic boolean completed(T result)
public boolean failed(java.lang.Exception exception)
public boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<T>public boolean cancel()
cancel in interface Cancellable