Package ghidra.async

Interface AsyncUtils


public interface AsyncUtils
Some conveniences when dealing with Java's CompletableFutures.
  • Field Details

  • Method Details

    • nil

      static <T> CompletableFuture<T> nil()
    • unwrapThrowable

      static Throwable unwrapThrowable(Throwable e)
      Unwrap CompletionExceptions and ExecutionExceptions to get the real cause
      Parameters:
      e - the (usually wrapped) exception
      Returns:
      the nearest cause in the chain that is not a CompletionException
    • copyTo

      static <T> BiFunction<T,Throwable,T> copyTo(CompletableFuture<T> dest)
      Create a BiFunction that copies a result from one CompletableFuture to another

      The returned function is suitable for use in CompletableFuture.handle(BiFunction) and related methods, as in:

       sourceCF().handle(AsyncUtils.copyTo(destCF));
       

      This will effectively cause destCF to be completed identically to sourceCF. The returned future from handle will also behave identically to source CF, except that destCF is guaranteed to complete before the returned future does.

      Type Parameters:
      T - the type of the future result
      Parameters:
      dest - the future to copy into
      Returns:
      a function which handles the source future