public interface BaseFuture extends Cancellable
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 |
addCancellation(Cancellable cancellable)
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 |
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.
|
String |
getFailedReason()
The default failed reason is Unknown.
|
BaseFuture.FutureType |
getType()
If the type is not OK, then something unexpected happened.
|
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 |
removeListener(BaseFutureListener<? extends BaseFuture> listener)
Removes a listener which is notified when the state of this future
changes.
|
BaseFuture |
setFailed(BaseFuture origin)
Sets the failed flat to true and the completed flag to true.
|
BaseFuture |
setFailed(String reason)
Sets the failed flat to true and the completed flag to true.
|
BaseFuture |
setFailed(String reason,
BaseFuture origin)
Sets the failed flat to true and the completed flag to true.
|
BaseFuture |
setFailed(String reason,
Throwable t)
Sets the failed flat to true and the completed flag to true.
|
BaseFuture |
setFailed(Throwable t)
Sets the failed flat to true and the completed flag to true.
|
cancel
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 setFailed(String reason)
reason
- The reason of failureBaseFuture setFailed(BaseFuture origin)
origin
- The origin of failureBaseFuture setFailed(String reason, BaseFuture origin)
reason
- The reason of failureorigin
- The origin of failureBaseFuture setFailed(Throwable t)
t
- The stack trace where the failure happenedBaseFuture setFailed(String reason, Throwable t)
reason
- The reason of failuret
- The stack trace where the failure happenedString getFailedReason()
BaseFuture.FutureType getType()
BaseFuture awaitListeners() throws InterruptedException
InterruptedException
- If interrupted from outsideBaseFuture 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 addCancellation(Cancellable cancellable)
cancellable
- A cancellable classCopyright © 2013. All Rights Reserved.