Uses of Interface
com.google.common.util.concurrent.ListenableFuture
-
Packages that use ListenableFuture Package Description com.google.common.cache This package contains caching utilities.com.google.common.util.concurrent Concurrency utilities. -
-
Uses of ListenableFuture in com.google.common.cache
Methods in com.google.common.cache that return ListenableFuture Modifier and Type Method Description ListenableFuture<V>
CacheLoader. reload(K key, V oldValue)
Computes or retrieves a replacement value corresponding to an already-cachedkey
. -
Uses of ListenableFuture in com.google.common.util.concurrent
Subinterfaces of ListenableFuture in com.google.common.util.concurrent Modifier and Type Interface Description interface
CheckedFuture<V,X extends java.lang.Exception>
ACheckedFuture
is aListenableFuture
that includes versions of theget
methods that can throw a checked exception.interface
ListenableScheduledFuture<V>
Helper interface to implement bothListenableFuture
andScheduledFuture
.Classes in com.google.common.util.concurrent that implement ListenableFuture Modifier and Type Class Description class
AbstractCheckedFuture<V,X extends java.lang.Exception>
A delegating wrapper around aListenableFuture
that adds support for theAbstractCheckedFuture.checkedGet()
andAbstractCheckedFuture.checkedGet(long, TimeUnit)
methods.class
AbstractFuture<V>
An abstract implementation ofListenableFuture
, intended for advanced users only.class
ForwardingCheckedFuture<V,X extends java.lang.Exception>
A future which forwards all its method calls to another future.static class
ForwardingCheckedFuture.SimpleForwardingCheckedFuture<V,X extends java.lang.Exception>
A simplified version ofForwardingCheckedFuture
where subclasses can pass in an already constructedCheckedFuture
as the delegate.class
ForwardingListenableFuture<V>
AListenableFuture
which forwards all its method calls to another future.static class
ForwardingListenableFuture.SimpleForwardingListenableFuture<V>
A simplified version ofForwardingListenableFuture
where subclasses can pass in an already constructedListenableFuture
as the delegate.class
ListenableFutureTask<V>
AFutureTask
that also implements theListenableFuture
interface.class
SettableFuture<V>
AListenableFuture
whose result may be set by aSettableFuture.set(Object)
,SettableFuture.setException(Throwable)
orSettableFuture.setFuture(ListenableFuture)
call.Methods in com.google.common.util.concurrent that return ListenableFuture Modifier and Type Method Description static <V> ListenableFuture<java.util.List<V>>
Futures. allAsList(ListenableFuture<? extends V>... futures)
Creates a newListenableFuture
whose value is a list containing the values of all its input futures, if all succeed.static <V> ListenableFuture<java.util.List<V>>
Futures. allAsList(java.lang.Iterable<? extends ListenableFuture<? extends V>> futures)
Creates a newListenableFuture
whose value is a list containing the values of all its input futures, if all succeed.ListenableFuture<O>
AsyncFunction. apply(I input)
Returns an outputFuture
to use in place of the giveninput
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catching(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catching(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback, java.util.concurrent.Executor executor)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catchingAsync(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, AsyncFunction<? super X,? extends V> fallback)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catchingAsync(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, AsyncFunction<? super X,? extends V> fallback, java.util.concurrent.Executor executor)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.ListenableFuture<V>
FutureFallback. create(java.lang.Throwable t)
Deprecated.Returns aFuture
to be used in place of theFuture
that failed with the given exception.protected abstract ListenableFuture<V>
ForwardingListenableFuture. delegate()
protected ListenableFuture<V>
ForwardingListenableFuture.SimpleForwardingListenableFuture. delegate()
static <V> ListenableFuture<V>
Futures. dereference(ListenableFuture<? extends ListenableFuture<? extends V>> nested)
Returns a newListenableFuture
whose result is the product of callingget()
on theFuture
nested within the givenFuture
, effectively chaining the futures one after the other.static <V> ListenableFuture<V>
Futures. immediateCancelledFuture()
Creates aListenableFuture
which is cancelled immediately upon construction, so thatisCancelled()
always returnstrue
.static <V> ListenableFuture<V>
Futures. immediateFailedFuture(java.lang.Throwable throwable)
Returns aListenableFuture
which has an exception set immediately upon construction.static <V> ListenableFuture<V>
Futures. immediateFuture(V value)
Creates aListenableFuture
which has its value set immediately upon construction.static <V> ListenableFuture<V>
JdkFutureAdapters. listenInPoolThread(java.util.concurrent.Future<V> future)
Assigns a thread to the givenFuture
to provideListenableFuture
functionality.static <V> ListenableFuture<V>
JdkFutureAdapters. listenInPoolThread(java.util.concurrent.Future<V> future, java.util.concurrent.Executor executor)
Submits a blocking task for the givenFuture
to provideListenableFuture
functionality.static <V> ListenableFuture<V>
Futures. nonCancellationPropagating(ListenableFuture<V> future)
Creates a newListenableFuture
whose result is set from the supplied future when it completes.ListenableFuture<?>
AbstractListeningExecutorService. submit(java.lang.Runnable task)
<T> ListenableFuture<T>
AbstractListeningExecutorService. submit(java.lang.Runnable task, T result)
<T> ListenableFuture<T>
AbstractListeningExecutorService. submit(java.util.concurrent.Callable<T> task)
ListenableFuture<?>
ForwardingListeningExecutorService. submit(java.lang.Runnable task)
<T> ListenableFuture<T>
ForwardingListeningExecutorService. submit(java.lang.Runnable task, T result)
<T> ListenableFuture<T>
ForwardingListeningExecutorService. submit(java.util.concurrent.Callable<T> task)
ListenableFuture<?>
ListeningExecutorService. submit(java.lang.Runnable task)
<T> ListenableFuture<T>
ListeningExecutorService. submit(java.lang.Runnable task, T result)
<T> ListenableFuture<T>
ListeningExecutorService. submit(java.util.concurrent.Callable<T> task)
static <V> ListenableFuture<java.util.List<V>>
Futures. successfulAsList(ListenableFuture<? extends V>... futures)
Creates a newListenableFuture
whose value is a list containing the values of all its successful input futures.static <V> ListenableFuture<java.util.List<V>>
Futures. successfulAsList(java.lang.Iterable<? extends ListenableFuture<? extends V>> futures)
Creates a newListenableFuture
whose value is a list containing the values of all its successful input futures.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, Function<? super I,? extends O> function)
Returns a newListenableFuture
whose result is the product of applying the givenFunction
to the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, Function<? super I,? extends O> function, java.util.concurrent.Executor executor)
Returns a newListenableFuture
whose result is the product of applying the givenFunction
to the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)
Deprecated.TheseAsyncFunction
overloads oftransform
are being renamed totransformAsync
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function, java.util.concurrent.Executor executor)
Deprecated.TheseAsyncFunction
overloads oftransform
are being renamed totransformAsync
.static <I,O>
ListenableFuture<O>Futures. transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)
Returns a newListenableFuture
whose result is asynchronously derived from the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function, java.util.concurrent.Executor executor)
Returns a newListenableFuture
whose result is asynchronously derived from the result of the givenFuture
.static <V> ListenableFuture<V>
Futures. withFallback(ListenableFuture<? extends V> input, FutureFallback<? extends V> fallback)
Deprecated.UsecatchingAsync(input, Throwable.class, fallbackImplementedAsAnAsyncFunction)
, usually replacingThrowable.class
with the specific type you want to handle.static <V> ListenableFuture<V>
Futures. withFallback(ListenableFuture<? extends V> input, FutureFallback<? extends V> fallback, java.util.concurrent.Executor executor)
Deprecated.UsecatchingAsync(input, Throwable.class, fallbackImplementedAsAnAsyncFunction, executor)
, usually replacingThrowable.class
with the specific type you want to handle.static <V> ListenableFuture<V>
Futures. withTimeout(ListenableFuture<V> delegate, long time, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService scheduledExecutor)
Returns a future that delegates to another but will finish early (via aTimeoutException
wrapped in anExecutionException
) if the specified duration expires.Methods in com.google.common.util.concurrent that return types with arguments of type ListenableFuture Modifier and Type Method Description static <T> ImmutableList<ListenableFuture<T>>
Futures. inCompletionOrder(java.lang.Iterable<? extends ListenableFuture<? extends T>> futures)
Returns a list of delegate futures that correspond to the futures received in the order that they complete.Methods in com.google.common.util.concurrent with parameters of type ListenableFuture Modifier and Type Method Description static <V> void
Futures. addCallback(ListenableFuture<V> future, FutureCallback<? super V> callback)
Registers separate success and failure callbacks to be run when theFuture
's computation is complete or, if the computation is already complete, immediately.static <V> void
Futures. addCallback(ListenableFuture<V> future, FutureCallback<? super V> callback, java.util.concurrent.Executor executor)
Registers separate success and failure callbacks to be run when theFuture
's computation is complete or, if the computation is already complete, immediately.static <V> ListenableFuture<java.util.List<V>>
Futures. allAsList(ListenableFuture<? extends V>... futures)
Creates a newListenableFuture
whose value is a list containing the values of all its input futures, if all succeed.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catching(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catching(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, Function<? super X,? extends V> fallback, java.util.concurrent.Executor executor)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catchingAsync(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, AsyncFunction<? super X,? extends V> fallback)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V,X extends java.lang.Throwable>
ListenableFuture<V>Futures. catchingAsync(ListenableFuture<? extends V> input, java.lang.Class<X> exceptionType, AsyncFunction<? super X,? extends V> fallback, java.util.concurrent.Executor executor)
Returns aFuture
whose result is taken from the given primaryinput
or, if the primary input fails with the givenexceptionType
, from the result provided by thefallback
.static <V> ListenableFuture<V>
Futures. dereference(ListenableFuture<? extends ListenableFuture<? extends V>> nested)
Returns a newListenableFuture
whose result is the product of callingget()
on theFuture
nested within the givenFuture
, effectively chaining the futures one after the other.static <V,X extends java.lang.Exception>
CheckedFuture<V,X>Futures. makeChecked(ListenableFuture<V> future, Function<? super java.lang.Exception,X> mapper)
Creates aCheckedFuture
out of a normalListenableFuture
and aFunction
that maps fromException
instances into the appropriate checked type.static <V> ListenableFuture<V>
Futures. nonCancellationPropagating(ListenableFuture<V> future)
Creates a newListenableFuture
whose result is set from the supplied future when it completes.protected boolean
AbstractFuture. setFuture(ListenableFuture<? extends V> future)
Sets the result of thisFuture
to match the supplied inputFuture
once the suppliedFuture
is done, unless thisFuture
has already been cancelled or set (including "set asynchronously," defined below).boolean
SettableFuture. setFuture(ListenableFuture<? extends V> future)
static <V> ListenableFuture<java.util.List<V>>
Futures. successfulAsList(ListenableFuture<? extends V>... futures)
Creates a newListenableFuture
whose value is a list containing the values of all its successful input futures.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, Function<? super I,? extends O> function)
Returns a newListenableFuture
whose result is the product of applying the givenFunction
to the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, Function<? super I,? extends O> function, java.util.concurrent.Executor executor)
Returns a newListenableFuture
whose result is the product of applying the givenFunction
to the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)
Deprecated.TheseAsyncFunction
overloads oftransform
are being renamed totransformAsync
.static <I,O>
ListenableFuture<O>Futures. transform(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function, java.util.concurrent.Executor executor)
Deprecated.TheseAsyncFunction
overloads oftransform
are being renamed totransformAsync
.static <I,O>
ListenableFuture<O>Futures. transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function)
Returns a newListenableFuture
whose result is asynchronously derived from the result of the givenFuture
.static <I,O>
ListenableFuture<O>Futures. transformAsync(ListenableFuture<I> input, AsyncFunction<? super I,? extends O> function, java.util.concurrent.Executor executor)
Returns a newListenableFuture
whose result is asynchronously derived from the result of the givenFuture
.static <V> ListenableFuture<V>
Futures. withFallback(ListenableFuture<? extends V> input, FutureFallback<? extends V> fallback)
Deprecated.UsecatchingAsync(input, Throwable.class, fallbackImplementedAsAnAsyncFunction)
, usually replacingThrowable.class
with the specific type you want to handle.static <V> ListenableFuture<V>
Futures. withFallback(ListenableFuture<? extends V> input, FutureFallback<? extends V> fallback, java.util.concurrent.Executor executor)
Deprecated.UsecatchingAsync(input, Throwable.class, fallbackImplementedAsAnAsyncFunction, executor)
, usually replacingThrowable.class
with the specific type you want to handle.static <V> ListenableFuture<V>
Futures. withTimeout(ListenableFuture<V> delegate, long time, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService scheduledExecutor)
Returns a future that delegates to another but will finish early (via aTimeoutException
wrapped in anExecutionException
) if the specified duration expires.Method parameters in com.google.common.util.concurrent with type arguments of type ListenableFuture Modifier and Type Method Description static <V> ListenableFuture<java.util.List<V>>
Futures. allAsList(java.lang.Iterable<? extends ListenableFuture<? extends V>> futures)
Creates a newListenableFuture
whose value is a list containing the values of all its input futures, if all succeed.static <V> ListenableFuture<V>
Futures. dereference(ListenableFuture<? extends ListenableFuture<? extends V>> nested)
Returns a newListenableFuture
whose result is the product of callingget()
on theFuture
nested within the givenFuture
, effectively chaining the futures one after the other.static <T> ImmutableList<ListenableFuture<T>>
Futures. inCompletionOrder(java.lang.Iterable<? extends ListenableFuture<? extends T>> futures)
Returns a list of delegate futures that correspond to the futures received in the order that they complete.static <V> ListenableFuture<java.util.List<V>>
Futures. successfulAsList(java.lang.Iterable<? extends ListenableFuture<? extends V>> futures)
Creates a newListenableFuture
whose value is a list containing the values of all its successful input futures.Constructors in com.google.common.util.concurrent with parameters of type ListenableFuture Constructor Description AbstractCheckedFuture(ListenableFuture<V> delegate)
Constructs anAbstractCheckedFuture
that wraps a delegate.SimpleForwardingListenableFuture(ListenableFuture<V> delegate)
-