/** * This call is similar to {@link #makeCompleteFuture(Iterable)} in that it will immediately * provide a future that will not be satisfied till all provided futures complete. * <p> * This future provides a list of the completed futures as the result. The order of the result * list will match the order returned by the provided {@link Iterable}. * <p> * If {@link ListenableFuture#cancel(boolean)} is invoked on the returned future, all provided * futures will attempt to be canceled in the same way. * * @since 1.2.0 * @param <T> The result object type returned from the futures * @param futures Structure of futures to iterate over * @return ListenableFuture which will be done once all futures provided are done */ public static <T> ListenableFuture<List<ListenableFuture<? extends T>>> makeCompleteListFuture(Iterable<? extends ListenableFuture<? extends T>> futures) { return new AllFutureCollection<>(futures); }
@Override protected void handleFutureDone(ListenableFuture<? extends T> f, int index) { addResult(f, index); } }
/** * This call is similar to {@link #makeCompleteFuture(Iterable)} in that it will immediately * provide a future that will not be satisfied till all provided futures complete. * <p> * This future provides a list of the completed futures as the result. The order of the result * list will match the order returned by the provided {@link Iterable}. * <p> * If {@link ListenableFuture#cancel(boolean)} is invoked on the returned future, all provided * futures will attempt to be canceled in the same way. * * @since 1.2.0 * @param <T> The result object type returned from the futures * @param futures Structure of futures to iterate over * @return ListenableFuture which will be done once all futures provided are done */ public static <T> ListenableFuture<List<ListenableFuture<? extends T>>> makeCompleteListFuture(Iterable<? extends ListenableFuture<? extends T>> futures) { return new AllFutureCollection<>(futures); }
@Override protected void handleFutureDone(ListenableFuture<? extends T> f, int index) { addResult(f, index); } }