public class Future<E> extends Object implements IFuture<E>, IForwardCommandFuture
IForwardCommandFuture.Type
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 |
abortGet(ISuspendable caller)
Abort a blocking get call.
|
void |
addForwardCommand(IFilter<Object> filter,
ICommand<Object> command)
Add a forward command with a filter.
|
void |
addResultListener(IResultListener<E> listener)
Add a result listener.
|
E |
get()
Get the result - blocking call.
|
E |
get(ISuspendable caller)
Get the result - blocking call.
|
E |
get(ISuspendable caller,
long timeout)
Get the result - blocking call.
|
E |
get(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 |
removeForwardCommand(ICommand<Object> command)
Add a command with a filter.
|
void |
sendForwardCommand(Object command)
Send a (forward) command to the listeners.
|
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 final 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()
public E get(long timeout)
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 abortGet(ISuspendable caller)
public void addResultListener(IResultListener<E> listener)
addResultListener
in interface IFuture<E>
listsner
- The listener.public void sendForwardCommand(Object command)
sendForwardCommand
in interface IForwardCommandFuture
command
- The command.public void addForwardCommand(IFilter<Object> filter, ICommand<Object> command)
Copyright © 2013. All Rights Reserved.