V
- public abstract class AbstractInvocationFuture<V> extends Object implements InternalCompletableFuture<V>
CompletableFuture
.
The long term goal is that this whole class can be ripped out and replaced
by CompletableFuture
from the JDK. So we need
to be very careful with adding more functionality to this class because
the more we add, the more
difficult the replacement will be.
TODO: - thread value protection
Modifier and Type | Field and Description |
---|---|
protected Executor |
defaultExecutor |
protected ILogger |
logger |
Modifier | Constructor and Description |
---|---|
protected |
AbstractInvocationFuture(Executor defaultExecutor,
ILogger logger) |
Modifier and Type | Method and Description |
---|---|
void |
andThen(ExecutionCallback<V> callback)
Registers a callback that will run after this future is completed.
|
void |
andThen(ExecutionCallback<V> callback,
Executor executor)
Registers a callback that will run with the provided executor after this
future is completed.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
boolean |
complete(Object value)
Can be called multiple times, but only the first answer will lead to the
future getting triggered.
|
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
protected Object |
getState() |
protected abstract String |
invocationToString() |
boolean |
isCancelled() |
boolean |
isDone() |
V |
join()
Waits for this future to complete.
|
protected abstract TimeoutException |
newTimeoutException(long timeout,
TimeUnit unit) |
protected void |
onComplete() |
protected void |
onInterruptDetected() |
protected Object |
resolve(Object value) |
protected abstract V |
resolveAndThrowIfException(Object state) |
String |
toString() |
protected Throwable |
unwrap(Throwable throwable) |
protected final Executor defaultExecutor
protected final ILogger logger
protected final Object getState()
protected void onInterruptDetected()
public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled
in interface Future<V>
public final V join()
InternalCompletableFuture
join
in interface InternalCompletableFuture<V>
public final V get() throws InterruptedException, ExecutionException
get
in interface Future<V>
InterruptedException
ExecutionException
public final V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<V>
InterruptedException
ExecutionException
TimeoutException
public void andThen(ExecutionCallback<V> callback)
ICompletableFuture
Please note that there is no ordering guarantee for running multiple callbacks. It is also not guaranteed that the callback will run within the same thread that completes the future.
andThen
in interface ICompletableFuture<V>
callback
- the callback to executepublic void andThen(ExecutionCallback<V> callback, Executor executor)
ICompletableFuture
executor
.
Please note that there is no ordering guarantee for executing multiple
callbacks.andThen
in interface ICompletableFuture<V>
callback
- the callback to executeexecutor
- the executor in which the callback will be runprotected abstract String invocationToString()
protected abstract V resolveAndThrowIfException(Object state) throws ExecutionException, InterruptedException
protected abstract TimeoutException newTimeoutException(long timeout, TimeUnit unit)
public final boolean complete(Object value)
complete
in interface InternalCompletableFuture<V>
value
- The type of response to offer.protected void onComplete()
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.