abstract class AggregateFuture.RunningState extends AggregateFutureState implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
private boolean |
allMustSucceed |
private boolean |
collectsValues |
private ImmutableCollection<? extends ListenableFuture<? extends InputT>> |
futures |
Constructor and Description |
---|
RunningState(ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures,
boolean allMustSucceed,
boolean collectsValues) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addInitialException(java.util.Set<java.lang.Throwable> seen)
Populates
seen with the exception that was passed to setException . |
(package private) abstract void |
collectOneValue(boolean allMustSucceed,
int index,
InputT returnValue)
Called only if
collectsValues is true. |
private void |
decrementCountAndMaybeComplete() |
(package private) abstract void |
handleAllCompleted() |
private void |
handleException(java.lang.Throwable throwable)
Fails this future with the given Throwable if
allMustSucceed is true. |
private void |
handleOneInputDone(int index,
java.util.concurrent.Future<? extends InputT> future)
Handles the input at the given index completing.
|
private void |
init()
The "real" initialization; we can't put this in the constructor because, in the case where
futures are already complete, we would not initialize the subclass before calling
handleOneInputDone(int, java.util.concurrent.Future<? extends InputT>) . |
(package private) void |
interruptTask() |
private void |
processCompleted() |
(package private) void |
releaseResourcesAfterFailure()
Listeners implicitly keep a reference to
AggregateFuture.RunningState as they're inner classes, so we
free resources here as well for the allMustSucceed=true case (i.e. |
void |
run() |
decrementRemainingAndGet, getOrInitSeenExceptions
private ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures
private final boolean allMustSucceed
private final boolean collectsValues
RunningState(ImmutableCollection<? extends ListenableFuture<? extends InputT>> futures, boolean allMustSucceed, boolean collectsValues)
public final void run()
run
in interface java.lang.Runnable
private void init()
handleOneInputDone(int, java.util.concurrent.Future<? extends InputT>)
. As this is called after the subclass is constructed, we're guaranteed
to have properly initialized the subclass.private void handleException(java.lang.Throwable throwable)
allMustSucceed
is true. Also, logs the
throwable if it is an Error
or if allMustSucceed
is true
, the
throwable did not cause this future to fail, and it is the first time we've seen that
particular Throwable.final void addInitialException(java.util.Set<java.lang.Throwable> seen)
AggregateFutureState
seen
with the exception that was passed to setException
.addInitialException
in class AggregateFutureState
private void handleOneInputDone(int index, java.util.concurrent.Future<? extends InputT> future)
private void decrementCountAndMaybeComplete()
private void processCompleted()
void releaseResourcesAfterFailure()
AggregateFuture.RunningState
as they're inner classes, so we
free resources here as well for the allMustSucceed=true case (i.e. when a future fails, we
immediately release resources we no longer need); additionally, the future will release its
reference to AggregateFuture.RunningState
, which should free all associated memory when all the
futures complete and the listeners are released.
TODO(user): Write tests for memory retentionabstract void collectOneValue(boolean allMustSucceed, int index, @Nullable InputT returnValue)
collectsValues
is true.
If allMustSucceed
is true, called as each future completes; otherwise, called for
each future when all futures complete.
abstract void handleAllCompleted()
void interruptTask()