Class CallbackUtils

java.lang.Object
com.apple.foundationdb.util.CallbackUtils

public class CallbackUtils extends Object
A utility to invoke a collection of callbacks with an effort to ensure all are called when facing errors.
  • 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.InvokeResults with a list of results returned from successful invocations and a CallbackException that 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 of CompletableFuture and 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 CompletedSuccessfully if all futures were created and completed successfully, or an exception that holds all the exceptions that were thrown during the process