public class Future<E> extends Object implements IFuture<E>
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Debug flag.
|
static IFuture<?> |
EMPTY
The empty future.
|
static boolean |
NO_STACK_COMPACTION
Disable Stack unfolding for easier debugging.
|
static ThreadLocal<List<Tuple2<Future<?>,IResultListener<?>>>> |
STACK
Notification stack for unwinding call stack to topmost future.
|
Constructor and Description |
---|
Future()
Create a new future.
|
Future(E result)
Create a future that is already done.
|
Future(Exception exception)
Create a future that is already failed.
|
Modifier and Type | Method and Description |
---|---|
void |
addResultListener(IResultListener<E> listener)
Add a result listener.
|
E |
get(ISuspendable caller)
Get the result - blocking call.
|
E |
get(ISuspendable caller,
long timeout)
Get the result - blocking call.
|
static <T> IFuture<T> |
getEmptyFuture()
Get the empty future of some type.
|
Exception |
getException()
Get the exception, if any.
|
boolean |
isDone()
Test if done, i.e. result is available.
|
void |
setException(Exception exception)
Set the exception.
|
boolean |
setExceptionIfUndone(Exception exception)
Set the exception.
|
void |
setResult(E result)
Set the result.
|
boolean |
setResultIfUndone(E result)
Set the result.
|
public static ThreadLocal<List<Tuple2<Future<?>,IResultListener<?>>>> STACK
public static boolean DEBUG
public static boolean NO_STACK_COMPACTION
public static final IFuture<?> EMPTY
public Future()
public Future(E result)
result
- The result, if any.public Future(Exception exception)
exception
- The exception.public static <T> IFuture<T> getEmptyFuture()
public boolean isDone()
public Exception getException()
getException
in interface IFuture<E>
public E get(ISuspendable caller)
public E get(ISuspendable caller, long timeout)
public void setException(Exception exception)
exception
- The exception.public boolean setExceptionIfUndone(Exception exception)
exception
- The exception.public void setResult(E result)
result
- The result.public boolean setResultIfUndone(E result)
result
- The result.public void addResultListener(IResultListener<E> listener)
addResultListener
in interface IFuture<E>
listsner
- The listener.Copyright © 2012. All Rights Reserved.