Package com.apple.foundationdb.util
Class CallbackUtils
java.lang.Object
com.apple.foundationdb.util.CallbackUtils
A utility to invoke a collection of callbacks with an effort to ensure all are called when facing errors.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CallbackUtils.InvokeResults<T>A utility to invoke multiple callbacks and return their results.static <T> CompletableFuture<Void>invokeAllFutures(List<Supplier<CompletableFuture<T>>> callbacks) A utility to invoke multiple suppliers ofCompletableFutureand wait for the future's completion.
-
Method Details
-
invokeAll
@API(INTERNAL) @Nonnull public static <T> CallbackUtils.InvokeResults<T> invokeAll(@Nonnull List<Supplier<T>> callbacks) A utility to invoke multiple callbacks and return their results. This method guarantees that each of the callbacks is invoked (regardless of whether previous calls threw an exception). The returned result holds the result of every successful call and an exception that holds every thrown exception (null if none).- Parameters:
callbacks- the given callbacks to invoke- Returns:
- an
CallbackUtils.InvokeResultswith a list of results returned from successful invocations and aCallbackExceptionthat holds the exceptions thrown during unsuccessful invocations
-
invokeAllFutures
@API(INTERNAL) @Nonnull public static <T> CompletableFuture<Void> invokeAllFutures(@Nonnull List<Supplier<CompletableFuture<T>>> callbacks) A utility to invoke multiple suppliers ofCompletableFutureand wait for the future's completion. This method guarantees that each of the callbacks is invoked and that each of the futures is accounted for regardless of whether they succeed or fail.- Parameters:
callbacks- the given sequence of callbacks- Returns:
- a future that completes when all the produced futures complete. The returned future's result is
CompletedSuccessfullyif all futures were created and completed successfully, or an exception that holds all the exceptions that were thrown during the process
-