Package jadex.future

Class FutureBarrier<E>

java.lang.Object
jadex.future.FutureBarrier<E>

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

    • futures

      protected List<IFuture<E>> futures
      The list of futures.
  • Constructor Details

    • FutureBarrier

      public FutureBarrier()
  • Method Details

    • addFuture

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

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

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

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

      public IFuture<Collection<E>> waitForResultsIgnoreFailures(jadex.common.ICommand<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.