FutureImpl implementation.
(Based on the JDK java.)
Future
| Modifier and Type | Class and Description |
|---|---|
| private class | SafeFutureImpl.
Synchronization control for FutureTask. |
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private Set | |
| private final SafeFutureImpl | sync
Synchronization control for FutureTask |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addCompletionHandler(final CompletionHandler<R> completionHandler)
Implements org. Adds a |
| public boolean | cancel(boolean mayInterruptIfRunning)
Implements java. Attempts to cancel execution of this task. |
| public static <R> SafeFutureImpl | |
| protected void | done()
Protected method invoked when this task transitions to state isDone (whether normally or via cancellation). |
| public void | failure(Throwable failure)
Implements org. Notify about the failure, occurred during asynchronous operation execution. |
| public R | get()
Implements java. Waits if necessary for the computation to complete, and then retrieves its result. |
| public R | get(long timeout, TimeUnit unit)
Implements java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available. |
| public R | getResult()
Implements org. Get current result value without any blocking. |
| public boolean | isCancelled()
Implements java. Returns |
| public boolean | |
| public void | markForRecycle(boolean recycleResult)
Implements org. Mark GrizzlyFuture as recyclable, so once result will come - GrizzlyFuture object will be recycled and returned to a thread local object pool. |
| private void | notifyCompletionHandler(final CompletionHandler<R> completionHandler)
Notify single |
| private void | |
| protected void | |
| public void | recycle(boolean recycleResult)
Implements org. Recycle GrizzlyFuture now. |
| public void | |
| public void | result(R
the result value result)Implements org. Set the result value and notify about operation completion. |
| chSync | back to summary |
|---|---|
| private final Object chSync | |
| completionHandlers | back to summary |
|---|---|
| private Set<CompletionHandler<R>> completionHandlers | |
| sync | back to summary |
|---|---|
| private final SafeFutureImpl<R>. Synchronization control for FutureTask | |
| SafeFutureImpl | back to summary |
|---|---|
| public SafeFutureImpl() Creates SafeFutureImpl
| |
| addCompletionHandler | back to summary |
|---|---|
| public void addCompletionHandler(final CompletionHandler<R> completionHandler) Implements org. Doc from org. Adds a
| |
| cancel | back to summary |
|---|---|
| public boolean cancel(boolean mayInterruptIfRunning) Implements java. Doc from java. Attempts to cancel execution of this task. This method has no
effect if the task is already completed or cancelled, or could
not be cancelled for some other reason. Otherwise, if this
task has not started when The return value from this method does not necessarily
indicate whether the task is now cancelled; use
| |
| create | back to summary |
|---|---|
| public static <R> SafeFutureImpl Construct
| |
| done | back to summary |
|---|---|
| protected void done() Protected method invoked when this task transitions to state isDone (whether normally or via cancellation). The default implementation does nothing. Subclasses may override this method to invoke completion callbacks or perform bookkeeping. Note that you can query status inside the implementation of this method to determine whether this task has been cancelled. | |
| failure | back to summary |
|---|---|
| public void failure(Throwable failure) Implements org. Notify about the failure, occurred during asynchronous operation execution.
| |
| get | back to summary |
|---|---|
| public R get() throws InterruptedException, ExecutionException Implements java. Doc from java. Waits if necessary for the computation to complete, and then retrieves its result.
| |
| get | back to summary |
|---|---|
| public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Implements java. Doc from java. Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
| |
| getResult | back to summary |
|---|---|
| public R getResult() Implements org. Doc from org. Get current result value without any blocking.
| |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Implements java. Doc from java. Returns
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Implements java. Doc from java. Returns
| |
| markForRecycle | back to summary |
|---|---|
| public void markForRecycle(boolean recycleResult) Implements org. Doc from org. Mark GrizzlyFuture as recyclable, so once result will come - GrizzlyFuture object will be recycled and returned to a thread local object pool. You can consider to use this method, if you're not interested in using this GrizzlyFuture object.
| |
| notifyCompletionHandler | back to summary |
|---|---|
| private void notifyCompletionHandler(final CompletionHandler<R> completionHandler) Notify single | |
| notifyCompletionHandlers | back to summary |
|---|---|
| private void notifyCompletionHandlers() Notify registered | |
| onComplete | back to summary |
|---|---|
| protected void onComplete() The method is called when this SafeFutureImpl is marked as completed. Subclasses can override this method. | |
| recycle | back to summary |
|---|---|
| public void recycle(boolean recycleResult) Implements org. Doc from org. Recycle GrizzlyFuture now. This method could be used, if you're not interested in using this GrizzlyFuture object, and you're sure this object is not used by any other application part.
| |
| recycle | back to summary |
|---|---|
| public void recycle() Implements org.
| |
| result | back to summary |
|---|---|
| public void result(R result) Implements org. Set the result value and notify about operation completion.
| |
Uses AQS sync state to represent run status
| Modifier and Type | Field and Description |
|---|---|
| private static final int | CANCELLED
Hides java. |
| private Throwable | exception
The exception to throw from get() |
| private static final int | RAN
State value representing that task ran |
| private static final int | READY
State value representing that task is ready to run |
| private static final int | RESULT
State value representing that result/exception is being set |
| private R | result
The result to return from get() |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| pack-priv R | |
| pack-priv R | |
| pack-priv boolean | |
| pack-priv void | |
| pack-priv void | |
| private boolean | |
| protected int | tryAcquireShared(int ignore)
Overrides java. Implements AQS base acquire to succeed if ran or cancelled |
| protected boolean | tryReleaseShared(int ignore)
Overrides java. Implements AQS base release to always signal after setting final done status by nulling runner thread. |
| CANCELLED | back to summary |
|---|---|
| private static final int CANCELLED Hides java. State value representing that task was cancelled | |
| exception | back to summary |
|---|---|
| private Throwable exception The exception to throw from get() | |
| RAN | back to summary |
|---|---|
| private static final int RAN State value representing that task ran | |
| READY | back to summary |
|---|---|
| private static final int READY State value representing that task is ready to run | |
| RESULT | back to summary |
|---|---|
| private static final int RESULT State value representing that result/exception is being set | |
| result | back to summary |
|---|---|
| private R result The result to return from get() | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides java. | |
| Sync | back to summary |
|---|---|
| private Sync() | |
| innerCancel | back to summary |
|---|---|
| pack-priv boolean innerCancel(boolean mayInterruptIfRunning) | |
| innerGet | back to summary |
|---|---|
| pack-priv R innerGet() throws InterruptedException, ExecutionException | |
| innerGet | back to summary |
|---|---|
| pack-priv R innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException | |
| innerIsCancelled | back to summary |
|---|---|
| pack-priv boolean innerIsCancelled() | |
| innerSet | back to summary |
|---|---|
| pack-priv void innerSet(R v) | |
| innerSetException | back to summary |
|---|---|
| pack-priv void innerSetException(Throwable t) | |
| ranOrCancelled | back to summary |
|---|---|
| private boolean ranOrCancelled() | |
| tryAcquireShared | back to summary |
|---|---|
| protected int tryAcquireShared(int ignore) Overrides java. Implements AQS base acquire to succeed if ran or cancelled
| |
| tryReleaseShared | back to summary |
|---|---|
| protected boolean tryReleaseShared(int ignore) Overrides java. Implements AQS base release to always signal after setting final done status by nulling runner thread.
| |