Class AggregateFuture.RunningState

    • Method Detail

      • run

        public final void run()
        Specified by:
        run in interface java.lang.Runnable
      • init

        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>). As this is called after the subclass is constructed, we're guaranteed to have properly initialized the subclass.
      • handleException

        private void handleException​(java.lang.Throwable throwable)
        Fails this future with the given Throwable if 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.
      • handleOneInputDone

        private void handleOneInputDone​(int index,
                                        java.util.concurrent.Future<? extends InputT> future)
        Handles the input at the given index completing.
      • decrementCountAndMaybeComplete

        private void decrementCountAndMaybeComplete()
      • processCompleted

        private void processCompleted()
      • releaseResourcesAfterFailure

        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. 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 retention

      • collectOneValue

        abstract void collectOneValue​(boolean allMustSucceed,
                                      int index,
                                      InputT returnValue)
        Called only if collectsValues is true.

        If allMustSucceed is true, called as each future completes; otherwise, called for each future when all futures complete.

      • handleAllCompleted

        abstract void handleAllCompleted()
      • interruptTask

        void interruptTask()