final class TimeoutFuture<V> extends FluentFuture.TrustedFuture<V>
Futures#withTimeout.
Future that delegates to another but will finish early (via a TimeoutException wrapped
in an ExecutionException) if the specified duration expires. The delegate future is
interrupted and cancelled if it times out.
| Modifier and Type | Class and Description |
|---|---|
private static class |
TimeoutFuture.Fire<V>
A runnable that is called when the delegate or the timer completes.
|
private static class |
TimeoutFuture.TimeoutFutureException |
FluentFuture.TrustedFuture<V>AbstractFuture.Trusted<V>| Modifier and Type | Field and Description |
|---|---|
private ListenableFuture<V> |
delegateRef |
private java.util.concurrent.ScheduledFuture<?> |
timer |
GENERATE_CANCELLATION_CAUSES| Modifier | Constructor and Description |
|---|---|
private |
TimeoutFuture(ListenableFuture<V> delegate) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterDone()
Callback method that is called exactly once after the future is completed.
|
(package private) static <V> ListenableFuture<V> |
create(ListenableFuture<V> delegate,
long time,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.ScheduledExecutorService scheduledExecutor) |
protected java.lang.String |
pendingToString()
Provide a human-readable explanation of why this future has not yet completed.
|
addListener, cancel, get, get, isCancelled, isDoneaddCallback, catching, catchingAsync, from, from, transform, transformAsync, withTimeout, withTimeoutinterruptTask, maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted@CheckForNull private ListenableFuture<V> delegateRef
@CheckForNull private java.util.concurrent.ScheduledFuture<?> timer
private TimeoutFuture(ListenableFuture<V> delegate)
static <V> ListenableFuture<V> create(ListenableFuture<V> delegate, long time, java.util.concurrent.TimeUnit unit, java.util.concurrent.ScheduledExecutorService scheduledExecutor)
@CheckForNull protected java.lang.String pendingToString()
AbstractFuturependingToString in class AbstractFuture<V>protected void afterDone()
AbstractFutureIf AbstractFuture.interruptTask() is also run during completion, AbstractFuture.afterDone() runs after it.
The default implementation of this method in AbstractFuture does nothing. This is
intended for very lightweight cleanup work, for example, timing statistics or clearing fields.
If your task does anything heavier consider, just using a listener with an executor.
afterDone in class AbstractFuture<V>