public abstract class BaseFutureImpl extends Object implements BaseFuture
BaseFuture.FutureType| Modifier and Type | Field and Description |
|---|---|
protected boolean |
completed |
protected Object |
lock |
protected String |
reason |
protected BaseFuture.FutureType |
type |
| Constructor and Description |
|---|
BaseFutureImpl() |
| 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 |
await()
Wait for the asynchronous operation to end.
|
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to end with the specified timeout.
|
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.
|
void |
cancel()
This method gets called if a future is cancelled.
|
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).
|
protected void |
notifyListerenrs()
Always call this from outside synchronized(lock)!
|
BaseFuture |
removeCancellation(Cancellable cancellable)
Remove a listener.
|
BaseFuture |
removeListener(BaseFutureListener<? extends BaseFuture> listener)
Removes a listener which is notified when the state of this future
changes.
|
protected boolean |
setCompletedAndNotify()
Make sure that the calling method has synchronized (lock)
|
void |
setFailed(String reason)
Sets the failed flat to true and the completed flag to true.
|
protected final Object lock
protected boolean completed
protected BaseFuture.FutureType type
protected String reason
public BaseFuture await() throws InterruptedException
BaseFutureawait in interface BaseFutureInterruptedException - if thread is interruptedpublic BaseFuture awaitUninterruptibly()
BaseFutureawaitUninterruptibly in interface BaseFuturepublic boolean await(long timeoutMillis)
throws InterruptedException
BaseFutureawait in interface BaseFuturetimeoutMillis - time to wait at mostInterruptedException - if thread is interruptedpublic boolean awaitUninterruptibly(long timeoutMillis)
BaseFutureawaitUninterruptibly in interface BaseFuturepublic boolean isCompleted()
BaseFutureisCompleted in interface BaseFuturepublic boolean isSuccess()
BaseFutureisSuccess in interface BaseFuturepublic boolean isFailed()
BaseFutureisFailed in interface BaseFuturepublic void setFailed(String reason)
BaseFuturesetFailed in interface BaseFuturepublic String getFailedReason()
BaseFuturegetFailedReason in interface BaseFuturepublic BaseFuture.FutureType getType()
BaseFuturegetType in interface BaseFutureprotected boolean setCompletedAndNotify()
public BaseFuture addListener(BaseFutureListener<? extends BaseFuture> listener)
BaseFutureaddListener in interface BaseFuturelistener - The listener extends the BaseFutureprotected void notifyListerenrs()
public BaseFuture removeListener(BaseFutureListener<? extends BaseFuture> listener)
BaseFutureremoveListener in interface BaseFuturelistener - The listener extends the BaseFuturepublic BaseFuture addCancellation(Cancellable cancellable)
BaseFutureaddCancellation in interface BaseFuturecancellable - A cancellable classpublic BaseFuture removeCancellation(Cancellable cancellable)
BaseFutureremoveCancellation in interface BaseFuturecancellable - A cancellable classpublic void cancel()
Cancellablecancel in interface CancellableCopyright © 2011. All Rights Reserved.