public final class FuturePromise<RESULT> extends java.util.concurrent.FutureTask<RESULT> implements Promise<RESULT>
FutureTask that implements the Promise interface to provide completion, failure, and cancellation
callbacks. By default, the callbacks run on the same thread that executes this task. To force a specific thread,
provide
an Executor to FuturePromise(Callable, Executor) or FuturePromise(Runnable, Object, Executor)Promise.OnCancelListener, Promise.OnCompleteListener<RESULT>, Promise.OnFailListener| Constructor and Description |
|---|
FuturePromise(java.util.concurrent.Callable<RESULT> callable)
Wrap a
Callable |
FuturePromise(java.util.concurrent.Callable<RESULT> callable,
java.util.concurrent.Executor executor)
Wrap a
Callable and provide an Executor for the callbacks. |
FuturePromise(java.lang.Runnable runnable,
RESULT resultHolder)
Wrap a
Runnable |
FuturePromise(java.lang.Runnable runnable,
RESULT resultHolder,
java.util.concurrent.Executor executor)
Wrap a
Runnable and provide an Executor for the callbacks. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
done() |
boolean |
isFailed()
|
FuturePromise<RESULT> |
onCancel(Promise.OnCancelListener listener)
|
FuturePromise<RESULT> |
onComplete(Promise.OnCompleteListener<RESULT> listener)
|
FuturePromise<RESULT> |
onFail(Promise.OnFailListener listener)
|
boolean |
succeeded()
Was the promise successfully completed?
|
cancel, get, get, isCancelled, isDone, run, runAndReset, set, setExceptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisCancelled, isDonepublic FuturePromise(java.util.concurrent.Callable<RESULT> callable)
Callablecallable - callable to get the result frompublic FuturePromise(java.util.concurrent.Callable<RESULT> callable, java.util.concurrent.Executor executor)
Callable and provide an Executor for the callbacks.callable - callable to get the result fromexecutor - an Executor on which the callbacks will executepublic FuturePromise(java.lang.Runnable runnable,
RESULT resultHolder)
Runnablerunnable - Runnable to get the result fromresultHolder - The result placeholderpublic FuturePromise(java.lang.Runnable runnable,
RESULT resultHolder,
java.util.concurrent.Executor executor)
Runnable and provide an Executor for the callbacks.runnable - Runnable to get the result fromresultHolder - The result placeholderexecutor - an Executor on which the callbacks will executepublic boolean succeeded()
public final FuturePromise<RESULT> onComplete(Promise.OnCompleteListener<RESULT> listener)
onComplete in interface Promise<RESULT>listener - listener to notify on completionpublic final FuturePromise<RESULT> onFail(Promise.OnFailListener listener)
public final FuturePromise<RESULT> onCancel(Promise.OnCancelListener listener)
public boolean isFailed()
protected void done()
done in class java.util.concurrent.FutureTask<RESULT>