Class FutureUtils
java.lang.Object
org.elasticsearch.common.util.concurrent.FutureUtils
public class FutureUtils
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description FutureUtils() -
Method Summary
Modifier and Type Method Description static booleancancel(java.util.concurrent.Future<?> toCancel)Cancel execution of this future without interrupting a running thread.static <T> Tget(java.util.concurrent.Future<T> future)CallsFuture.get()without the checked exceptions.static <T> Tget(java.util.concurrent.Future<T> future, long timeout, java.util.concurrent.TimeUnit unit)CallsFuture.get(long, TimeUnit)without the checked exceptions.static java.lang.RuntimeExceptionrethrowExecutionException(java.util.concurrent.ExecutionException e)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
FutureUtils
public FutureUtils()
-
-
Method Details
-
cancel
public static boolean cancel(@Nullable java.util.concurrent.Future<?> toCancel)Cancel execution of this future without interrupting a running thread. SeeFuture.cancel(boolean)for details.- Parameters:
toCancel- the future to cancel- Returns:
- false if the future could not be cancelled, otherwise true
-
get
public static <T> T get(java.util.concurrent.Future<T> future)CallsFuture.get()without the checked exceptions.- Type Parameters:
T- the type returned- Parameters:
future- to dereference- Returns:
- the value of the future
-
get
public static <T> T get(java.util.concurrent.Future<T> future, long timeout, java.util.concurrent.TimeUnit unit)CallsFuture.get(long, TimeUnit)without the checked exceptions.- Type Parameters:
T- the type returned- Parameters:
future- to dereferencetimeout- to waitunit- for timeout- Returns:
- the value of the future
-
rethrowExecutionException
public static java.lang.RuntimeException rethrowExecutionException(java.util.concurrent.ExecutionException e)
-