Interface CheckedFuture<V,X extends Exception>
- All Superinterfaces:
Future<V>
,org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture<V>
- All Known Subinterfaces:
DrillRpcFuture<T>
- All Known Implementing Classes:
AbstractCheckedFuture
,RpcCheckedFuture
public interface CheckedFuture<V,X extends Exception>
extends org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture<V>
A
CheckedFuture
is a ListenableFuture
that includes versions of the get
methods that can throw a checked exception. This makes it easier to create a future that executes
logic which can throw an exception.
Implementations of this interface must adapt the exceptions thrown by Future#get()
:
CancellationException
, ExecutionException
and InterruptedException
into
the type specified by the X
type parameter.
This interface also extends the ListenableFuture interface to allow listeners to be added.
This allows the future to be used as a normal Future
or as an asynchronous callback
mechanism as needed. This allows multiple callbacks to be registered for a particular task, and
the future will guarantee execution of all listeners when the task completes.
For a simpler alternative to CheckedFuture, consider accessing Future values with Futures.getChecked()
.
This interface is moved from Guava, since there it was deleted.
-
Method Summary
Modifier and TypeMethodDescriptionException checking version ofFuture.get()
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions.checkedGet
(long timeout, TimeUnit unit) Exception checking version ofFuture.get(long, TimeUnit)
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions.Methods inherited from interface org.apache.drill.shaded.guava.com.google.common.util.concurrent.ListenableFuture
addListener
-
Method Details
-
checkedGet
Exception checking version ofFuture.get()
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions.- Returns:
- the result of executing the future.
- Throws:
X
- on interruption, cancellation or execution exceptions.
-
checkedGet
Exception checking version ofFuture.get(long, TimeUnit)
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions. On timeout this method throws a normalTimeoutException
.- Returns:
- the result of executing the future.
- Throws:
TimeoutException
- if retrieving the result timed out.X
- on interruption, cancellation or execution exceptions.
-