javadoc.com.google.common.util.concurrent.CheckedFuture.html Maven / Gradle / Ivy
CheckedFuture (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.util.concurrent
Interface CheckedFuture<V,X extends Exception>
- All Superinterfaces:
- Future<V>, ListenableFuture<V>
- All Known Implementing Classes:
- AbstractCheckedFuture, ForwardingCheckedFuture, ForwardingCheckedFuture.SimpleForwardingCheckedFuture
@Beta
public interface CheckedFuture<V,X extends Exception>
- extends 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.
A common implementation is Futures.immediateCheckedFuture(V)
.
Implementations of this interface must adapt the exceptions thrown by
Future#get()
: CancellationException
,
ExecutionException
and InterruptedException
into the type
specified by the E
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.get()
.
- Since:
- 1.0
- Author:
- Sven Mawson
Method Summary | |
---|---|
V |
checkedGet()
Exception checking version of Future.get() that will translate
InterruptedException , CancellationException and
ExecutionException into application-specific exceptions. |
V |
checkedGet(long timeout,
TimeUnit unit)
Exception checking version of Future.get(long, TimeUnit) that will
translate InterruptedException , CancellationException and
ExecutionException into application-specific exceptions. |
Methods inherited from interface com.google.common.util.concurrent.ListenableFuture |
---|
addListener |
Methods inherited from interface java.util.concurrent.Future |
---|
cancel, get, get, isCancelled, isDone |
Method Detail |
---|
checkedGet
V checkedGet() throws X extends Exception
- Exception checking version of
Future.get()
that will translateInterruptedException
,CancellationException
andExecutionException
into application-specific exceptions.
checkedGet
V checkedGet(long timeout, TimeUnit unit) throws TimeoutException, X extends Exception
- Exception checking version of
Future.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.X extends Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.