ff = f.toCompletableFuture();
751 |
752 | return CompletableFuture.allOf(af, bf, cf, df, ef, ff)
753 | .thenCompose(ignored -> function.apply(af.join(),
754 | bf.join(),
755 | cf.join(),
756 | df.join(),
757 | ef.join(),
758 | ff.join()));
759 | }
760 |
761 | /**
762 | * Polls an external resource periodically until it returns a non-empty result.
763 | *
764 | * The polling task should return {@code Optional.empty()} until it becomes available, and
765 | * then {@code Optional.of(result)}. If the polling task throws an exception or returns null,
766 | * that will cause the result future to complete exceptionally.
767 | *
768 | *
Canceling the returned future will cancel the scheduled polling task as well.
769 | *
770 | *
Note that on a ScheduledThreadPoolExecutor the polling task might remain allocated for up
771 | * to {@code frequency} time after completing or being cancelled. If you have lots of polling
772 | * operations or a long polling frequency, consider setting {@code removeOnCancelPolicy} to true.
773 | * See {@link java.util.concurrent.ScheduledThreadPoolExecutor#setRemoveOnCancelPolicy(boolean)}.
774 | *
775 | * @param pollingTask the polling task
776 | * @param frequency the frequency to run the polling task at
777 | * @param executorService the executor service to schedule the polling task on
778 | * @param