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.
|
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.
|
boolean |
isDone()
Test if done, i.e. result is available.
|
static void |
main(String[] args)
Main for testing.
|
void |
setException(Exception exception)
Set the exception.
|
void |
setExceptionIfUndone(Exception exception)
Set the exception.
|
void |
setResult(E result)
Set the result.
|
void |
setResultIfUndone(E result)
Set the result.
|
public static final boolean DEBUG
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 E get(ISuspendable caller)
public E get(ISuspendable caller, long timeout)
public void setException(Exception exception)
exception
- The exception.public void setExceptionIfUndone(Exception exception)
exception
- The exception.public void setResult(E result)
result
- The result.public void 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.