public interface IFutureWithListeners<RESULT> extends Future<RESULT>
| Modifier and Type | Method and Description |
|---|---|
void |
addFutureListener(IFutureListener<RESULT> listener)
Adds a listener on a future status (using strong reference).
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
computationException(Exception e)
Informs the future that it can't be computed due to the exception.
|
RESULT |
get() |
RESULT |
get(long timeout,
TimeUnit unit)
Returns a result or waits for the computation till timeout.
|
Exception |
getException()
Contains an exception that has happened during the computation in the case of (
FutureWithListeners.getStatus() == EXCEPTION). |
FutureStatus |
getStatus()
Current status of the future computation.
|
boolean |
isCancelled() |
boolean |
isDone() |
boolean |
isListening(IFutureListener<RESULT> listener)
Whether some listener is listening on the future.
|
void |
removeFutureListener(IFutureListener<RESULT> listener)
Removes a listener from the future.
|
void |
setResult(RESULT result)
Sets the result of the future computation.
|
void addFutureListener(IFutureListener<RESULT> listener)
listener - boolean cancel(boolean mayInterruptIfRunning)
void computationException(Exception e)
Switches the status to EXCEPTION (notifying listeners along the way).
The result can be set only iff NOT FutureWithListeners.isDone(), i.e., status is FutureStatus:FUTURE_IS_BEING_COMPUTED.
e - RESULT get(long timeout, TimeUnit unit)
Does not throw TimeoutException! It returns null instead - always examine status of the future
via FutureWithListeners.getStatus() if the null is returned to tell whether the 'null' is the
result of the computation (if the status is FUTURE_IS_READY than the 'null' is truly the result).
Exception getException()
FutureWithListeners.getStatus() == EXCEPTION).FutureStatus getStatus()
boolean isCancelled()
isCancelled in interface Future<RESULT>boolean isListening(IFutureListener<RESULT> listener)
listener - void removeFutureListener(IFutureListener<RESULT> listener)
listener - void setResult(RESULT result)
Switches the status to FUTURE_IS_READY (notifying listeners along the way).
The result can be set only iff NOT FutureWithListeners.isDone(), i.e., status is FutureStatus:FUTURE_IS_BEING_COMPUTED.
result - Copyright © 2019 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All rights reserved.