T - The type of the object to be returned.public class SettableVTNFuture<T> extends AbstractVTNFuture<T>
VTNFuture that requires the task result to be
set externally.| Constructor and Description |
|---|
SettableVTNFuture() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean intr)
Attempt to cancel execution of the task.
|
T |
get()
Wait for the task to complete, and then return the result of the task.
|
T |
get(long timeout,
TimeUnit unit)
Wait for the task to complete, and then return the result of the task.
|
boolean |
isCancelled()
Determine whether the task was canceled before it completed normally.
|
boolean |
isDone()
Determine whether the task completed or not.
|
protected boolean |
maskCancel()
Mask cancellation temporarily.
|
protected void |
onFutureFailed(Throwable cause)
Invoked when the computation has completed abnormally.
|
protected void |
onFutureSucceeded(T result)
Invoked when the computation has completed normally.
|
boolean |
set(T result)
Set the result of the task associated with the future.
|
boolean |
setException(Throwable cause)
Set a
Throwable that indicates the cause of error. |
boolean |
setThread(Thread t)
Set a thread that is executing the task.
|
protected boolean |
unmaskCancel()
Unmask cancellation masked by the previous call of
maskCancel(). |
addListener, done, getCause, getExceptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckedGet, checkedGetpublic final boolean setThread(Thread t)
t - A Thread instance.true only if the task has already been canceled.public final boolean set(T result)
Subclass needs to call this method when the computation is complete.
result - A value returned by the task.true if the future state has been changed.
false if the task already completed.public final boolean setException(Throwable cause)
Throwable that indicates the cause of error.
Subclass needs to call this method when the task has caught an unhandled exception.
cause - A Throwable instance.true if the future state has been changed.
false if the task already completed.protected final boolean maskCancel()
throws InterruptedException
This method is expected to be called on the thread that is executing the task. This method has no effect if the task is already completed successfully.
true on success.
false if the task has already completed.InterruptedException - The task has already been canceled.protected final boolean unmaskCancel()
throws InterruptedException
maskCancel().
This method is expected to be called on the thread that is executing the task. This method has no effect if the task is already completed successfully.
true on success.
false if the task has already completed.InterruptedException - The task has already been canceled.protected void onFutureSucceeded(T result)
Note that this method is called prior to
FutureCallback.
result - The result of the task.protected void onFutureFailed(Throwable cause)
Note that this method is called prior to
FutureCallback.
cause - A Throwable that indicates the cause of failure.public boolean cancel(boolean intr)
intr - true if the task runner thread should be
interrupted. Otherwise in-progress task are allowed
to complete.true only if the task was canceled.public boolean isCancelled()
true only if the task was canceled.public boolean isDone()
true only if the task completed.public T get() throws InterruptedException, ExecutionException
CancellationException - The task was canceled.InterruptedException - The current thread was interrupted while waiting.ExecutionException - The task caught an exception.public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
timeout - The maximum time to waitunit - The time unit of timeout.CancellationException - The task was canceled.InterruptedException - The current thread was interrupted while waiting.ExecutionException - The task caught an exception.TimeoutException - The task did not complete within the given timeout.Copyright © 2018 OpenDaylight. All rights reserved.