Class CombinedFuture<V>
- java.lang.Object
-
- com.google.common.util.concurrent.internal.InternalFutureFailureAccess
-
- com.google.common.util.concurrent.AbstractFuture<V>
-
- com.google.common.util.concurrent.AbstractFuture.TrustedFuture<OutputT>
-
- com.google.common.util.concurrent.AggregateFutureState<OutputT>
-
- com.google.common.util.concurrent.AggregateFuture<java.lang.Object,V>
-
- com.google.common.util.concurrent.CombinedFuture<V>
-
- All Implemented Interfaces:
AbstractFuture.Trusted<V>
,ListenableFuture<V>
,java.util.concurrent.Future<V>
final class CombinedFuture<V> extends AggregateFuture<java.lang.Object,V>
Aggregate future that computes its value by calling a callable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CombinedFuture.AsyncCallableInterruptibleTask
private class
CombinedFuture.CallableInterruptibleTask
private class
CombinedFuture.CombinedFutureInterruptibleTask<T>
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AggregateFuture
AggregateFuture.ReleaseResourcesReason
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.AbstractFuture
AbstractFuture.Trusted<V>, AbstractFuture.TrustedFuture<V>
-
-
Field Summary
Fields Modifier and Type Field Description private CombinedFuture.CombinedFutureInterruptibleTask<?>
task
-
Constructor Summary
Constructors Constructor Description CombinedFuture(ImmutableCollection<? extends ListenableFuture<?>> futures, boolean allMustSucceed, java.util.concurrent.Executor listenerExecutor, AsyncCallable<V> callable)
CombinedFuture(ImmutableCollection<? extends ListenableFuture<?>> futures, boolean allMustSucceed, java.util.concurrent.Executor listenerExecutor, java.util.concurrent.Callable<V> callable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
collectOneValue(int index, java.lang.Object returnValue)
IfallMustSucceed
is true, called as each future completes; otherwise, ifcollectsValues
is true, called for each future when all futures complete.(package private) void
handleAllCompleted()
protected void
interruptTask()
Subclasses can override this method to implement interruption of the future's computation.(package private) void
releaseResources(AggregateFuture.ReleaseResourcesReason reason)
Clears fields that are no longer needed after this future has completed -- or at least all its inputs have completed (more precisely, afterAggregateFuture.handleAllCompleted()
has been called).-
Methods inherited from class com.google.common.util.concurrent.AggregateFuture
addInitialException, afterDone, init, pendingToString
-
Methods inherited from class com.google.common.util.concurrent.AggregateFutureState
clearSeenExceptions, decrementRemainingAndGet, getOrInitSeenExceptions
-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture.TrustedFuture
addListener, cancel, get, get, isCancelled, isDone
-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
maybePropagateCancellationTo, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
-
-
-
-
Field Detail
-
task
private CombinedFuture.CombinedFutureInterruptibleTask<?> task
-
-
Constructor Detail
-
CombinedFuture
CombinedFuture(ImmutableCollection<? extends ListenableFuture<?>> futures, boolean allMustSucceed, java.util.concurrent.Executor listenerExecutor, AsyncCallable<V> callable)
-
CombinedFuture
CombinedFuture(ImmutableCollection<? extends ListenableFuture<?>> futures, boolean allMustSucceed, java.util.concurrent.Executor listenerExecutor, java.util.concurrent.Callable<V> callable)
-
-
Method Detail
-
collectOneValue
void collectOneValue(int index, java.lang.Object returnValue)
Description copied from class:AggregateFuture
IfallMustSucceed
is true, called as each future completes; otherwise, ifcollectsValues
is true, called for each future when all futures complete.- Specified by:
collectOneValue
in classAggregateFuture<java.lang.Object,V>
-
handleAllCompleted
void handleAllCompleted()
- Specified by:
handleAllCompleted
in classAggregateFuture<java.lang.Object,V>
-
releaseResources
void releaseResources(AggregateFuture.ReleaseResourcesReason reason)
Description copied from class:AggregateFuture
Clears fields that are no longer needed after this future has completed -- or at least all its inputs have completed (more precisely, afterAggregateFuture.handleAllCompleted()
has been called). Often called multiple times (that is, both when the inputs complete and when the output completes).This is similar to our proposed
afterCommit
method but not quite the same. See the description of CL 265462958.- Overrides:
releaseResources
in classAggregateFuture<java.lang.Object,V>
-
interruptTask
protected void interruptTask()
Description copied from class:AbstractFuture
Subclasses can override this method to implement interruption of the future's computation. The method is invoked automatically by a successful call tocancel(true)
.The default implementation does nothing.
This method is likely to be deprecated. Prefer to override
AbstractFuture.afterDone()
, checkingAbstractFuture.wasInterrupted()
to decide whether to interrupt your task.- Overrides:
interruptTask
in classAbstractFuture<V>
-
-