Class FutureBarrier<E>


  • public class FutureBarrier<E>
    extends java.lang.Object
    A future barrier allows for waiting for a variable number of futures. Calling waitFor will wait until all futures are done.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<IFuture<E>> futures
      The list of futures.
    • Constructor Summary

      Constructors 
      Constructor Description
      FutureBarrier()  
    • Field Detail

      • futures

        protected java.util.List<IFuture<E>> futures
        The list of futures.
    • Constructor Detail

      • FutureBarrier

        public FutureBarrier()
    • Method Detail

      • addFuture

        public void addFuture​(IFuture<E> fut)
        Add a future to the barrier.
        Parameters:
        fut - The future.
      • waitFor

        public IFuture<java.lang.Void> waitFor()
        Wait for all added futures being finished.
      • waitForIgnoreFailures

        public IFuture<java.lang.Void> waitForIgnoreFailures​(ICommand<java.lang.Exception> failurehandler)
        Wait for all added futures being finished. Ignore failures and call optional failure handler, if any.
      • waitForResults

        public IFuture<java.util.Collection<E>> waitForResults()
        Wait for all added futures being finished and collect the results.
      • waitForResultsIgnoreFailures

        public IFuture<java.util.Collection<E>> waitForResultsIgnoreFailures​(ICommand<java.lang.Exception> failurehandler)
        Wait for all added futures being finished and collect the results. Ignore failures and call optional failure handler, if any.
      • getResult

        public E getResult​(int index)
        Get the nth result. Must be called after the barrier is due.
        Parameters:
        index - The index.
      • getCount

        public int getCount()
        Get the number of futures. May be called before the barrier is done.