Class BaseFuture<V>
java.lang.Object
org.elasticsearch.common.util.concurrent.BaseFuture<V>
- All Implemented Interfaces:
Future<V>
- Direct Known Subclasses:
AdapterActionFuture,ListenableFuture,PlainTransportFuture
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleancancel(boolean mayInterruptIfRunning)protected voiddone(boolean success)Called when theBaseFutureis completed.get()protected voidSubclasses can override this method to implement interruption of the future's computation.booleanbooleanisDone()protected booleanSubclasses should invoke this method to set the result of the computation tovalue.protected booleansetException(Throwable throwable)Subclasses should invoke this method to set the result of the computation to an error,throwable.
-
Constructor Details
-
BaseFuture
public BaseFuture()
-
-
Method Details
-
get
public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionExceptionThe default
BaseFutureimplementation throwsInterruptedExceptionif the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedException- if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionTimeoutExceptionExecutionException
-
get
The default
BaseFutureimplementation throwsInterruptedExceptionif the current thread is interrupted before or during the call, even if the value is already available.- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedException- if the current thread was interrupted before or during the call (optional but recommended).CancellationExceptionExecutionException
-
blockingAllowed
protected boolean blockingAllowed() -
isDone
public boolean isDone() -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceFuture<V>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
interruptTask
protected void interruptTask()Subclasses can override this method to implement interruption of the future's computation. The method is invoked automatically by a successful call tocancel(true).The default implementation does nothing.
- Since:
- 10.0
-
set
Subclasses should invoke this method to set the result of the computation tovalue. This will set the state of the future toBaseFuture.Sync.COMPLETEDand calldone(boolean)if the state was successfully changed.- Parameters:
value- the value that was the result of the task.- Returns:
- true if the state was successfully changed.
-
setException
Subclasses should invoke this method to set the result of the computation to an error,throwable. This will set the state of the future toBaseFuture.Sync.COMPLETEDand calldone(boolean)if the state was successfully changed. -
done
protected void done(boolean success)Called when theBaseFutureis completed. Thesuccessboolean indicates if theBaseFuturewas successfully completed (the value istrue). In the cases theBaseFuturewas completed with an error or cancelled the value isfalse.- Parameters:
success- indicates if theBaseFuturewas completed with success (true); in other cases it equals to false
-