K - The class that extends BaseFuture and is used to return back the type for method calls. E.g, if K is
FutureDHT await() returns FutureDHT.public abstract class BaseFutureImpl<K extends BaseFuture> 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()
Default constructor that sets the lock object, which is used for synchronization to this instance.
|
| Modifier and Type | Method and Description |
|---|---|
K |
addCancel(Cancel cancelListener)
Adds a cancel listener to this future, which is called when cancel is executed.
|
K |
addListener(BaseFutureListener<? extends BaseFuture> listener)
Adds a listener which is notified when the state of this future changes.
|
K |
addListener(BaseFutureListener<? extends BaseFuture> listener,
boolean last)
Adds a listener which is notified when the state of this future changes.
|
K |
await()
Wait for the asynchronous operation to end.
|
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to end with the specified timeout.
|
K |
awaitListeners()
Waits until all the listener finished.
|
K |
awaitListenersUninterruptibly()
Waits uninterruptedly until all the listener finished.
|
K |
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.
|
protected boolean |
completedAndNotify()
Make sure that the calling method has synchronized (lock).
|
K |
failed(BaseFuture origin)
Sets the failed flag to true and the completed flag to true.
|
K |
failed(String failed)
Sets the failed flag to true and the completed flag to true.
|
K |
failed(String failed,
BaseFuture origin)
Sets the failed flag to true and the completed flag to true.
|
K |
failed(String failed,
Throwable t)
Sets the failed flag to true and the completed flag to true.
|
K |
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).
|
protected void |
notifyListeners()
Always call this from outside synchronized(lock)!
|
K |
removeCancel(Cancel cancelListener)
Removes a cancel listener to this future.
|
K |
removeListener(BaseFutureListener<? extends BaseFuture> listener)
Removes a listener which is notified when the state of this future changes.
|
protected K |
self() |
protected void |
self(K self2) |
BaseFuture.FutureType |
type()
If the type is not OK, then something unexpected happened.
|
protected final Object lock
protected boolean completed
protected BaseFuture.FutureType type
protected String reason
public BaseFutureImpl()
protected void self(K self2)
self2 - Set the type so that we are able to return it to the user. This is for making the API much more
usable.protected K self()
public K await() throws InterruptedException
BaseFutureawait in interface BaseFutureInterruptedException - if thread is interruptedpublic K 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 BaseFuturetimeoutMillis - to wait at mostpublic boolean isCompleted()
BaseFutureisCompleted in interface BaseFuturepublic boolean isSuccess()
BaseFutureisSuccess in interface BaseFuturepublic boolean isFailed()
BaseFutureisFailed in interface BaseFuturepublic K failed(BaseFuture origin)
BaseFuturefailed in interface BaseFutureorigin - The origin of failurepublic K failed(String failed, BaseFuture origin)
BaseFuturefailed in interface BaseFuturefailed - The reason of failureorigin - The origin of failurepublic K failed(Throwable t)
BaseFuturefailed in interface BaseFuturet - The stack trace where the failure happenedpublic K failed(String failed, Throwable t)
BaseFuturefailed in interface BaseFuturefailed - The reason of failuret - The stack trace where the failure happenedpublic K failed(String failed)
BaseFuturefailed in interface BaseFuturefailed - The reason of failurepublic String failedReason()
BaseFuturefailedReason in interface BaseFuturepublic BaseFuture.FutureType type()
BaseFuturetype in interface BaseFutureprotected boolean completedAndNotify()
public K awaitListeners() throws InterruptedException
BaseFutureawaitListeners in interface BaseFutureInterruptedException - If interrupted from outsidepublic K awaitListenersUninterruptibly()
BaseFutureawaitListenersUninterruptibly in interface BaseFuturepublic K addListener(BaseFutureListener<? extends BaseFuture> listener)
BaseFutureaddListener in interface BaseFuturelistener - The listener extends the BaseFuturepublic K addListener(BaseFutureListener<? extends BaseFuture> listener, boolean last)
BaseFutureaddListener in interface BaseFuturelistener - 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 firstprotected void notifyListeners()
public K removeListener(BaseFutureListener<? extends BaseFuture> listener)
BaseFutureremoveListener in interface BaseFuturelistener - The listener extends the BaseFuturepublic K addCancel(Cancel cancelListener)
BaseFutureaddCancel in interface BaseFuturecancelListener - The cancel listenerpublic K removeCancel(Cancel cancelListener)
BaseFutureremoveCancel in interface BaseFuturecancelListener - The cancel listenerCopyright © 2014. All rights reserved.