Package jadex.commons.future
Class FutureBarrier<E>
- java.lang.Object
-
- jadex.commons.future.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.
-
-
Constructor Summary
Constructors Constructor Description FutureBarrier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFuture(IFuture<E> fut)
Add a future to the barrier.int
getCount()
Get the number of futures.E
getResult(int index)
Get the nth result.IFuture<java.lang.Void>
waitFor()
Wait for all added futures being finished.IFuture<java.lang.Void>
waitForIgnoreFailures(ICommand<java.lang.Exception> failurehandler)
Wait for all added futures being finished.IFuture<java.util.Collection<E>>
waitForResults()
Wait for all added futures being finished and collect the results.IFuture<java.util.Collection<E>>
waitForResultsIgnoreFailures(ICommand<java.lang.Exception> failurehandler)
Wait for all added futures being finished and collect the results.
-
-
-
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.
-
-