public interface BaseFuture extends Cancel
| Modifier and Type | Interface and Description |
|---|---|
static class |
BaseFuture.FutureType
The first state is always INIT and will always end in either OK, FAILED, or CANCEL.
|
| Modifier and Type | Method and Description |
|---|---|
BaseFuture |
addCancel(Cancel cancel)
Adds a cancel listener to this future, which is called when cancel is executed.
|
BaseFuture |
addListener(BaseFutureListener<? extends BaseFuture> listener)
Adds a listener which is notified when the state of this future changes.
|
BaseFuture |
addListener(BaseFutureListener<? extends BaseFuture> listener,
boolean last)
Adds a listener which is notified when the state of this future changes.
|
BaseFuture |
await()
Wait for the asynchronous operation to end.
|
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to end with the specified timeout.
|
BaseFuture |
awaitListeners()
Waits until all the listener finished.
|
BaseFuture |
awaitListenersUninterruptibly()
Waits uninterruptedly until all the listener finished.
|
BaseFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to end without interruption.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to end with the specified timeout without interruption.
|
BaseFuture |
failed(BaseFuture origin)
Sets the failed flag to true and the completed flag to true.
|
BaseFuture |
failed(String reason)
Sets the failed flag to true and the completed flag to true.
|
BaseFuture |
failed(String reason,
BaseFuture origin)
Sets the failed flag to true and the completed flag to true.
|
BaseFuture |
failed(String reason,
Throwable t)
Sets the failed flag to true and the completed flag to true.
|
BaseFuture |
failed(Throwable t)
Sets the failed flag to true and the completed flag to true.
|
String |
failedReason()
The default failed reason is Unknown.
|
boolean |
isCompleted()
Checks if the asynchronous operation is finished.
|
boolean |
isFailed()
Checks if operation has failed.
|
boolean |
isSuccess()
Returns the opposite of isFailed (returns !isFailed).
|
BaseFuture |
removeCancel(Cancel cancel)
Removes a cancel listener to this future.
|
BaseFuture |
removeListener(BaseFutureListener<? extends BaseFuture> listener)
Removes a listener which is notified when the state of this future changes.
|
BaseFuture.FutureType |
type()
If the type is not OK, then something unexpected happened.
|
BaseFuture await() throws InterruptedException
InterruptedException - if thread is interruptedboolean await(long timeoutMillis)
throws InterruptedException
timeoutMillis - time to wait at mostInterruptedException - if thread is interruptedBaseFuture awaitUninterruptibly()
boolean awaitUninterruptibly(long timeoutMillis)
timeoutMillis - to wait at mostboolean isCompleted()
boolean isSuccess()
boolean isFailed()
BaseFuture failed(String reason)
reason - The reason of failureBaseFuture failed(BaseFuture origin)
origin - The origin of failureBaseFuture failed(String reason, BaseFuture origin)
reason - The reason of failureorigin - The origin of failureBaseFuture failed(Throwable t)
t - The stack trace where the failure happenedBaseFuture failed(String reason, Throwable t)
reason - The reason of failuret - The stack trace where the failure happenedString failedReason()
BaseFuture.FutureType type()
BaseFuture awaitListeners() throws InterruptedException
InterruptedException - If interrupted from outsideBaseFuture awaitListenersUninterruptibly()
BaseFuture addListener(BaseFutureListener<? extends BaseFuture> listener)
listener - The listener extends the BaseFutureBaseFuture addListener(BaseFutureListener<? extends BaseFuture> listener, boolean last)
listener - The listener extends the BaseFuturelast - Set to true if the listener should be added at the end of the list, true if it should be added firstBaseFuture removeListener(BaseFutureListener<? extends BaseFuture> listener)
listener - The listener extends the BaseFutureBaseFuture addCancel(Cancel cancel)
cancel - The cancel listenerBaseFuture removeCancel(Cancel cancel)
cancel - The cancel listenerCopyright © 2014. All rights reserved.