V
- The result type returned by this Future's get
methodpublic abstract class AbstractCompletableFuture<V> extends Object implements ICompletableFuture<V>
ICompletableFuture
implementation that may be explicitly completed by setting its
value through setResult.
Implements the logic of cancellation and callbacks execution.Modifier | Constructor and Description |
---|---|
protected |
AbstractCompletableFuture(Executor defaultExecutor,
ILogger logger) |
protected |
AbstractCompletableFuture(NodeEngine nodeEngine,
ILogger logger) |
Modifier and Type | Method and Description |
---|---|
void |
andThen(ExecutionCallback<V> callback)
Registers a callback that will run after the future is completed.
|
void |
andThen(ExecutionCallback<V> callback,
Executor executor)
Registers a callback that will run with the provided executor after the future is completed.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
protected void |
cancelled(boolean mayInterruptIfRunning)
Protected method invoked when this task transitions to state
isCancelled . |
protected void |
done()
Protected method invoked when this task transitions to state
isDone (only normally - in case of cancellation cancelled() is invoked)
The default implementation does nothing. |
V |
get() |
V |
get(long timeout,
TimeUnit unit)
PLEASE NOTE: It's legal to override this method, but please bear in mind that you should call super.get() or
implement the done() and cancelled() callbacks to be notified if this future gets done or cancelled.
|
protected V |
getResult()
Returns:
null - if cancelled or not done
result - if done and result is NOT Throwable
sneaky throws an exception - if done and result is Throwable
|
boolean |
isCancelled() |
boolean |
isDone() |
protected void |
setResult(Object result) |
protected boolean |
shouldCancel(boolean mayInterruptIfRunning)
Protected method invoked on cancel().
|
protected AbstractCompletableFuture(NodeEngine nodeEngine, ILogger logger)
public void andThen(ExecutionCallback<V> callback)
ICompletableFuture
andThen
in interface ICompletableFuture<V>
callback
- the callback to executepublic void andThen(ExecutionCallback<V> callback, Executor executor)
ICompletableFuture
andThen
in interface ICompletableFuture<V>
callback
- the callback to executeexecutor
- the executor in which the callback will be runpublic final boolean cancel(boolean mayInterruptIfRunning)
protected boolean shouldCancel(boolean mayInterruptIfRunning)
mayInterruptIfRunning
- passed through from cancel callprotected void cancelled(boolean mayInterruptIfRunning)
isCancelled
. The default implementation does nothing.
Subclasses may override this method to invoke callbacks or perform
bookkeeping. Implementation has to handle exceptions itself.mayInterruptIfRunning
- true
if the thread executing this
task was supposed to be interrupted; otherwise, in-progress tasks are allowed
to completepublic boolean isCancelled()
isCancelled
in interface Future<V>
public final V get() throws InterruptedException, ExecutionException
get
in interface Future<V>
InterruptedException
ExecutionException
public V get(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
get
in interface Future<V>
ExecutionException
InterruptedException
TimeoutException
protected void setResult(Object result)
protected void done()
isDone
(only normally - in case of cancellation cancelled() is invoked)
The default implementation does nothing.
Subclasses may override this method to invoke callbacks or perform
bookkeeping. Implementation has to handle exceptions itself.protected V getResult()
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.