public final class MoreFutures extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
addExceptionCallback(com.google.common.util.concurrent.ListenableFuture<T> future,
java.util.function.Consumer<Throwable> exceptionCallback) |
static <T> void |
addExceptionCallback(com.google.common.util.concurrent.ListenableFuture<T> future,
Runnable exceptionCallback) |
static <T> CompletableFuture<T> |
addTimeout(CompletableFuture<T> future,
Callable<T> onTimeout,
io.airlift.units.Duration timeout,
ScheduledExecutorService executorService)
Deprecated.
|
static <T> com.google.common.util.concurrent.ListenableFuture<T> |
addTimeout(com.google.common.util.concurrent.ListenableFuture<T> future,
Callable<T> onTimeout,
io.airlift.units.Duration timeout,
ScheduledExecutorService executorService)
Returns a new future that is completed when the supplied future completes or
when the timeout expires.
|
static <V> CompletableFuture<List<V>> |
allAsList(List<CompletableFuture<? extends V>> futures)
Deprecated.
|
static void |
checkSuccess(Future<?> future,
String errorMessage)
Checks that the completed future completed successfully.
|
static <V> CompletableFuture<V> |
failedFuture(Throwable throwable)
Deprecated.
|
static <V> CompletableFuture<V> |
firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures)
Deprecated.
|
static <V> CompletableFuture<V> |
firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures,
boolean propagateCancel)
Deprecated.
|
static <T> T |
getDone(Future<T> future)
Returns the result of the input
Future, which must have already completed. |
static <V> V |
getFutureValue(Future<V> future)
Waits for the value from the future.
|
static <V,E extends Exception> |
getFutureValue(Future<V> future,
Class<E> exceptionType)
Waits for the value from the future.
|
static <T> void |
mirror(com.google.common.util.concurrent.ListenableFuture<? extends T> source,
com.google.common.util.concurrent.SettableFuture<? super T> destination,
boolean mayInterruptIfRunning)
Mirrors all results of the source Future to the destination Future.
|
static <X,Y> void |
propagateCancellation(com.google.common.util.concurrent.ListenableFuture<? extends X> source,
Future<? extends Y> destination,
boolean mayInterruptIfRunning)
Cancels the destination Future if the source Future is cancelled.
|
static <V> CompletableFuture<V> |
toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> listenableFuture)
Converts a ListenableFuture to a CompletableFuture.
|
static <V> com.google.common.util.concurrent.ListenableFuture<V> |
toListenableFuture(CompletableFuture<V> completableFuture)
Converts a CompletableFuture to a ListenableFuture.
|
static <T> Optional<T> |
tryGetFutureValue(Future<T> future)
Gets the current value of the future without waiting.
|
static <V> Optional<V> |
tryGetFutureValue(Future<V> future,
int timeout,
TimeUnit timeUnit)
Waits for the the value from the future for the specified time.
|
static <V,E extends Exception> |
tryGetFutureValue(Future<V> future,
int timeout,
TimeUnit timeUnit,
Class<E> exceptionType)
Waits for the the value from the future for the specified time.
|
static <V> CompletableFuture<V> |
unmodifiableFuture(CompletableFuture<V> future)
Deprecated.
|
static <V> CompletableFuture<V> |
unmodifiableFuture(CompletableFuture<V> future,
boolean propagateCancel)
Deprecated.
|
static Throwable |
unwrapCompletionException(Throwable throwable)
Attempts to unwrap a throwable that has been wrapped in a
CompletionException. |
static <V> com.google.common.util.concurrent.ListenableFuture<V> |
whenAnyComplete(Iterable<? extends com.google.common.util.concurrent.ListenableFuture<? extends V>> futures)
Creates a future that completes when the first future completes either normally
or exceptionally.
|
public static <X,Y> void propagateCancellation(com.google.common.util.concurrent.ListenableFuture<? extends X> source,
Future<? extends Y> destination,
boolean mayInterruptIfRunning)
public static <T> void mirror(com.google.common.util.concurrent.ListenableFuture<? extends T> source,
com.google.common.util.concurrent.SettableFuture<? super T> destination,
boolean mayInterruptIfRunning)
This also propagates cancellations from the destination Future back to the source Future.
public static Throwable unwrapCompletionException(Throwable throwable)
CompletionException.@Deprecated public static <V> CompletableFuture<V> unmodifiableFuture(CompletableFuture<V> future)
@Deprecated public static <V> CompletableFuture<V> unmodifiableFuture(CompletableFuture<V> future, boolean propagateCancel)
@Deprecated public static <V> CompletableFuture<V> failedFuture(Throwable throwable)
public static <V> V getFutureValue(Future<V> future)
public static <V,E extends Exception> V getFutureValue(Future<V> future, Class<E> exceptionType) throws E extends Exception
E extends Exceptionpublic static <T> Optional<T> tryGetFutureValue(Future<T> future)
public static <V> Optional<V> tryGetFutureValue(Future<V> future, int timeout, TimeUnit timeUnit)
public static <V,E extends Exception> Optional<V> tryGetFutureValue(Future<V> future, int timeout, TimeUnit timeUnit, Class<E> exceptionType) throws E extends Exception
E extends Exceptionpublic static <T> T getDone(Future<T> future)
Future, which must have already completed.
Similar to FuturesFutures.getDone(Future), but does not throw checked exceptions.
public static void checkSuccess(Future<?> future, String errorMessage)
public static <V> com.google.common.util.concurrent.ListenableFuture<V> whenAnyComplete(Iterable<? extends com.google.common.util.concurrent.ListenableFuture<? extends V>> futures)
@Deprecated public static <V> CompletableFuture<V> firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures)
@Deprecated public static <V> CompletableFuture<V> firstCompletedFuture(Iterable<? extends CompletionStage<? extends V>> futures, boolean propagateCancel)
@Deprecated public static <V> CompletableFuture<List<V>> allAsList(List<CompletableFuture<? extends V>> futures)
public static <T> com.google.common.util.concurrent.ListenableFuture<T> addTimeout(com.google.common.util.concurrent.ListenableFuture<T> future,
Callable<T> onTimeout,
io.airlift.units.Duration timeout,
ScheduledExecutorService executorService)
@Deprecated public static <T> CompletableFuture<T> addTimeout(CompletableFuture<T> future, Callable<T> onTimeout, io.airlift.units.Duration timeout, ScheduledExecutorService executorService)
public static <V> CompletableFuture<V> toCompletableFuture(com.google.common.util.concurrent.ListenableFuture<V> listenableFuture)
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(CompletableFuture<V> completableFuture)
public static <T> void addExceptionCallback(com.google.common.util.concurrent.ListenableFuture<T> future,
java.util.function.Consumer<Throwable> exceptionCallback)
public static <T> void addExceptionCallback(com.google.common.util.concurrent.ListenableFuture<T> future,
Runnable exceptionCallback)
Copyright © 2010-2017 Airlift. All Rights Reserved.