Package ghidra.async

# Interface AsyncUtils

public interface AsyncUtils
Some conveniences when dealing with Java's `CompletableFuture`s.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `AsyncUtils.TemperamentalRunnable`
  `static interface`
  `AsyncUtils.TemperamentalSupplier<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Cleaner`
  `CLEANER`
  `static final ExecutorService`
  `FRAMEWORK_EXECUTOR`
  `static final ExecutorService`
  `SWING_EXECUTOR`

- ## Method Summary

  Static Methods
  Modifier and Type
  Method
  Description
  `static <T> BiFunction<T,Throwable,T>`
  `copyTo(CompletableFuture<T> dest)`
  Create a `BiFunction` that copies a result from one `CompletableFuture` to another
  `static <T> CompletableFuture<T>`
  `nil()`
  `static Throwable`
  `unwrapThrowable(Throwable e)`
  Unwrap `CompletionException`s and `ExecutionException`s to get the real cause

- ## Field Details

  - ### CLEANER

    static final Cleaner CLEANER

  - ### FRAMEWORK_EXECUTOR

    static final ExecutorService FRAMEWORK_EXECUTOR

  - ### SWING_EXECUTOR

    static final ExecutorService SWING_EXECUTOR

- ## Method Details

  - ### nil

    static <T> CompletableFuture<T> nil()

  - ### unwrapThrowable

    static Throwable unwrapThrowable(Throwable e)
    Unwrap `CompletionException`s and `ExecutionException`s 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