Interface Promise<V>

Type Parameters:
V - the result type
All Superinterfaces:
AutoCloseable, Future<V>, Terminable

public interface Promise<V> extends Future<V>, Terminable
An object that acts as a proxy for a result that is initially unknown, usually because the computation of its value is yet incomplete.

This interface carries similar method signatures to those of CompletionStage and CompletableFuture.

However, a distinction is made between actions which are executed on the main server thread vs asynchronously.

  • Field Summary

    Fields inherited from interface dev.demeng.pluginbase.terminable.Terminable

    EMPTY
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Attempts to cancel execution of this task.
    static <U> @NotNull Promise<U>
    completed(U value)
    Returns a Promise which is already completed with the given value.
    static <U> @NotNull Promise<U>
    Returns a new empty Promise
    default @NotNull Promise<V>
    exceptionally(@NotNull ThreadContext context, @NotNull Function<Throwable,? extends V> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.
    static <U> @NotNull Promise<U>
    exceptionally(@NotNull Throwable exception)
    Returns a Promise which is already completed with the given exception.
    @NotNull Promise<V>
    exceptionallyAsync(@NotNull Function<Throwable,? extends V> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.
    default @NotNull Promise<V>
    exceptionallyDelayed(@NotNull ThreadContext context, @NotNull Function<Throwable,? extends V> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    default @NotNull Promise<V>
    exceptionallyDelayed(@NotNull ThreadContext context, @NotNull Function<Throwable,? extends V> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    @NotNull Promise<V>
    exceptionallyDelayedAsync(@NotNull Function<Throwable,? extends V> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    @NotNull Promise<V>
    exceptionallyDelayedAsync(@NotNull Function<Throwable,? extends V> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    @NotNull Promise<V>
    exceptionallyDelayedSync(@NotNull Function<Throwable,? extends V> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    @NotNull Promise<V>
    exceptionallyDelayedSync(@NotNull Function<Throwable,? extends V> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.
    @NotNull Promise<V>
    exceptionallySync(@NotNull Function<Throwable,? extends V> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.
    getNow(V valueIfAbsent)
    Returns the result value (or throws any encountered exception) if completed, else returns the given valueIfAbsent.
    Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.
    static @NotNull Promise<Void>
    Returns a new base promise to be built on top of.
    default @NotNull Promise<V>
    supply(@NotNull ThreadContext context, @NotNull Supplier<V> supplier)
    Schedules the supply of the Promise's result, via the given supplier.
    @NotNull Promise<V>
    supply(V value)
    Supplies the Promise's result.
    @NotNull Promise<V>
    supplyAsync(@NotNull Supplier<V> supplier)
    Schedules the supply of the Promise's result, via the given supplier.
    default @NotNull Promise<V>
    supplyDelayed(@NotNull ThreadContext context, @NotNull Supplier<V> supplier, long delayTicks)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    default @NotNull Promise<V>
    supplyDelayed(@NotNull ThreadContext context, @NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    @NotNull Promise<V>
    supplyDelayedAsync(@NotNull Supplier<V> supplier, long delayTicks)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    @NotNull Promise<V>
    supplyDelayedAsync(@NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    @NotNull Promise<V>
    supplyDelayedSync(@NotNull Supplier<V> supplier, long delayTicks)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    @NotNull Promise<V>
    supplyDelayedSync(@NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
    @NotNull Promise<V>
    supplyException(@NotNull Throwable exception)
    Supplies an exceptional result to the Promise.
    default @NotNull Promise<V>
    supplyExceptionally(@NotNull ThreadContext context, @NotNull Callable<V> callable)
    Schedules the supply of the Promise's result, via the given callable.
    @NotNull Promise<V>
    supplyExceptionallyAsync(@NotNull Callable<V> callable)
    Schedules the supply of the Promise's result, via the given callable.
    default @NotNull Promise<V>
    supplyExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<V> callable, long delayTicks)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    default @NotNull Promise<V>
    supplyExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    @NotNull Promise<V>
    supplyExceptionallyDelayedAsync(@NotNull Callable<V> callable, long delayTicks)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    @NotNull Promise<V>
    supplyExceptionallyDelayedAsync(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    @NotNull Promise<V>
    supplyExceptionallyDelayedSync(@NotNull Callable<V> callable, long delayTicks)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    @NotNull Promise<V>
    supplyExceptionallyDelayedSync(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit)
    Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
    @NotNull Promise<V>
    supplyExceptionallySync(@NotNull Callable<V> callable)
    Schedules the supply of the Promise's result, via the given callable.
    static <U> @NotNull Promise<U>
    supplying(@NotNull ThreadContext context, @NotNull Supplier<U> supplier)
    Returns a new Promise, and schedules it's population via the given supplier.
    static <U> @NotNull Promise<U>
    supplyingAsync(@NotNull Supplier<U> supplier)
    Returns a new Promise, and schedules it's population via the given supplier.
    static <U> @NotNull Promise<U>
    supplyingDelayed(@NotNull ThreadContext context, @NotNull Supplier<U> supplier, long delayTicks)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingDelayed(@NotNull ThreadContext context, @NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingDelayedAsync(@NotNull Supplier<U> supplier, long delayTicks)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingDelayedAsync(@NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingDelayedSync(@NotNull Supplier<U> supplier, long delayTicks)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingDelayedSync(@NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionally(@NotNull ThreadContext context, @NotNull Callable<U> callable)
    Returns a new Promise, and schedules it's population via the given callable.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyAsync(@NotNull Callable<U> callable)
    Returns a new Promise, and schedules it's population via the given callable.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<U> callable, long delayTicks)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayedAsync(@NotNull Callable<U> callable, long delayTicks)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayedAsync(@NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayedSync(@NotNull Callable<U> callable, long delayTicks)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallyDelayedSync(@NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit)
    Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
    static <U> @NotNull Promise<U>
    supplyingExceptionallySync(@NotNull Callable<U> callable)
    Returns a new Promise, and schedules it's population via the given callable.
    static <U> @NotNull Promise<U>
    supplyingSync(@NotNull Supplier<U> supplier)
    Returns a new Promise, and schedules it's population via the given supplier.
    @NotNull Promise<V>
    supplySync(@NotNull Supplier<V> supplier)
    Schedules the supply of the Promise's result, via the given supplier.
    default @NotNull Promise<Void>
    thenAccept(@NotNull ThreadContext context, @NotNull Consumer<? super V> action)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
    default @NotNull Promise<Void>
    thenAcceptAsync(@NotNull Consumer<? super V> action)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
    default @NotNull Promise<Void>
    thenAcceptDelayed(@NotNull ThreadContext context, @NotNull Consumer<? super V> action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptDelayed(@NotNull ThreadContext context, @NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptDelayedAsync(@NotNull Consumer<? super V> action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptDelayedAsync(@NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptDelayedSync(@NotNull Consumer<? super V> action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptDelayedSync(@NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenAcceptSync(@NotNull Consumer<? super V> action)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
    default <U> @NotNull Promise<U>
    thenApply(@NotNull ThreadContext context, @NotNull Function<? super V,? extends U> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    <U> @NotNull Promise<U>
    thenApplyAsync(@NotNull Function<? super V,? extends U> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    default <U> @NotNull Promise<U>
    thenApplyDelayed(@NotNull ThreadContext context, @NotNull Function<? super V,? extends U> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    default <U> @NotNull Promise<U>
    thenApplyDelayed(@NotNull ThreadContext context, @NotNull Function<? super V,? extends U> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenApplyDelayedAsync(@NotNull Function<? super V,? extends U> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenApplyDelayedAsync(@NotNull Function<? super V,? extends U> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenApplyDelayedSync(@NotNull Function<? super V,? extends U> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenApplyDelayedSync(@NotNull Function<? super V,? extends U> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenApplySync(@NotNull Function<? super V,? extends U> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    default <U> @NotNull Promise<U>
    thenCompose(@NotNull ThreadContext context, @NotNull Function<? super V,? extends Promise<U>> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    <U> @NotNull Promise<U>
    thenComposeAsync(@NotNull Function<? super V,? extends Promise<U>> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    <U> @NotNull Promise<U>
    thenComposeDelayedAsync(@NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenComposeDelayedAsync(@NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    default <U> @NotNull Promise<U>
    thenComposeDelayedSync(@NotNull ThreadContext context, @NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    default <U> @NotNull Promise<U>
    thenComposeDelayedSync(@NotNull ThreadContext context, @NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenComposeDelayedSync(@NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenComposeDelayedSync(@NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
    <U> @NotNull Promise<U>
    thenComposeSync(@NotNull Function<? super V,? extends Promise<U>> fn)
    Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
    default @NotNull Promise<Void>
    thenRun(@NotNull ThreadContext context, @NotNull Runnable action)
    Returns a new Promise that, when this promise completes normally, executes the given task.
    default @NotNull Promise<Void>
    thenRunAsync(@NotNull Runnable action)
    Returns a new Promise that, when this promise completes normally, executes the given task.
    default @NotNull Promise<Void>
    thenRunDelayed(@NotNull ThreadContext context, @NotNull Runnable action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunDelayed(@NotNull ThreadContext context, @NotNull Runnable action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunDelayedAsync(@NotNull Runnable action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunDelayedAsync(@NotNull Runnable action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunDelayedSync(@NotNull Runnable action, long delayTicks)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunDelayedSync(@NotNull Runnable action, long delay, @NotNull TimeUnit unit)
    Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
    default @NotNull Promise<Void>
    thenRunSync(@NotNull Runnable action)
    Returns a new Promise that, when this promise completes normally, executes the given task.
    Returns a CompletableFuture maintaining the same completion properties as this Promise.

    Methods inherited from interface java.util.concurrent.Future

    cancel, get, get, isCancelled, isDone

    Methods inherited from interface dev.demeng.pluginbase.terminable.Terminable

    bindWith, close, closeAndReportException, closeSilently, isClosed
  • Method Details

    • empty

      @NotNull static <U> @NotNull Promise<U> empty()
      Returns a new empty Promise

      An empty promise can be 'completed' via the supply methods.

      Type Parameters:
      U - the result type
      Returns:
      a new empty promise
    • start

      @NotNull static @NotNull Promise<Void> start()
      Returns a new base promise to be built on top of.
      Returns:
      a new promise
    • completed

      @NotNull static <U> @NotNull Promise<U> completed(@Nullable U value)
      Returns a Promise which is already completed with the given value.
      Type Parameters:
      U - the result type
      Parameters:
      value - the value
      Returns:
      a new completed promise
    • exceptionally

      @NotNull static <U> @NotNull Promise<U> exceptionally(@NotNull @NotNull Throwable exception)
      Returns a Promise which is already completed with the given exception.
      Type Parameters:
      U - the result type
      Parameters:
      exception - the exception
      Returns:
      the new completed promise
    • supplying

      @NotNull static <U> @NotNull Promise<U> supplying(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier)
      Returns a new Promise, and schedules it's population via the given supplier.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the value supplier
      Returns:
      the promise
    • supplyingSync

      @NotNull static <U> @NotNull Promise<U> supplyingSync(@NotNull @NotNull Supplier<U> supplier)
      Returns a new Promise, and schedules it's population via the given supplier.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      Returns:
      the promise
    • supplyingAsync

      @NotNull static <U> @NotNull Promise<U> supplyingAsync(@NotNull @NotNull Supplier<U> supplier)
      Returns a new Promise, and schedules it's population via the given supplier.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      Returns:
      the promise
    • supplyingDelayed

      @NotNull static <U> @NotNull Promise<U> supplyingDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier, long delayTicks)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the value supplier
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingDelayed

      @NotNull static <U> @NotNull Promise<U> supplyingDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the value supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • supplyingDelayedSync

      @NotNull static <U> @NotNull Promise<U> supplyingDelayedSync(@NotNull @NotNull Supplier<U> supplier, long delayTicks)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingDelayedSync

      @NotNull static <U> @NotNull Promise<U> supplyingDelayedSync(@NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • supplyingDelayedAsync

      @NotNull static <U> @NotNull Promise<U> supplyingDelayedAsync(@NotNull @NotNull Supplier<U> supplier, long delayTicks)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingDelayedAsync

      @NotNull static <U> @NotNull Promise<U> supplyingDelayedAsync(@NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      supplier - the value supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • supplyingExceptionally

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable)
      Returns a new Promise, and schedules it's population via the given callable.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the value callable
      Returns:
      the promise
    • supplyingExceptionallySync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallySync(@NotNull @NotNull Callable<U> callable)
      Returns a new Promise, and schedules it's population via the given callable.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      Returns:
      the promise
    • supplyingExceptionallyAsync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyAsync(@NotNull @NotNull Callable<U> callable)
      Returns a new Promise, and schedules it's population via the given callable.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      Returns:
      the promise
    • supplyingExceptionallyDelayed

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable, long delayTicks)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the value callable
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingExceptionallyDelayed

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the value callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • supplyingExceptionallyDelayedSync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedSync(@NotNull @NotNull Callable<U> callable, long delayTicks)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingExceptionallyDelayedSync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedSync(@NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • supplyingExceptionallyDelayedAsync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedAsync(@NotNull @NotNull Callable<U> callable, long delayTicks)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      delayTicks - the delay in ticks
      Returns:
      the promise
    • supplyingExceptionallyDelayedAsync

      @NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedAsync(@NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      callable - the value callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the promise
    • cancel

      default boolean cancel()
      Attempts to cancel execution of this task.
      Returns:
      false if the task could not be cancelled, typically because it has already completed normally; true otherwise
    • join

      V join()
      Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.

      To better conform with the use of common functional forms, if a computation involved in the completion of this Promise threw an exception, this method throws an (unchecked) CompletionException with the underlying exception as its cause.

      Returns:
      the result value
      Throws:
      CancellationException - if the computation was cancelled
      CompletionException - if this future completed exceptionally or a completion computation threw an exception
    • getNow

      V getNow(V valueIfAbsent)
      Returns the result value (or throws any encountered exception) if completed, else returns the given valueIfAbsent.
      Parameters:
      valueIfAbsent - the value to return if not completed
      Returns:
      the result value, if completed, else the given valueIfAbsent
      Throws:
      CancellationException - if the computation was cancelled
      CompletionException - if this future completed exceptionally or a completion computation threw an exception
    • supply

      @NotNull @NotNull Promise<V> supply(@Nullable V value)
      Supplies the Promise's result.
      Parameters:
      value - the object to pass to the promise
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyException

      @NotNull @NotNull Promise<V> supplyException(@NotNull @NotNull Throwable exception)
      Supplies an exceptional result to the Promise.
      Parameters:
      exception - the exception to supply
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supply

      @NotNull default @NotNull Promise<V> supply(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier)
      Schedules the supply of the Promise's result, via the given supplier.
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the supplier
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplySync

      @NotNull @NotNull Promise<V> supplySync(@NotNull @NotNull Supplier<V> supplier)
      Schedules the supply of the Promise's result, via the given supplier.
      Parameters:
      supplier - the supplier
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyAsync

      @NotNull @NotNull Promise<V> supplyAsync(@NotNull @NotNull Supplier<V> supplier)
      Schedules the supply of the Promise's result, via the given supplier.
      Parameters:
      supplier - the supplier
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayed

      @NotNull default @NotNull Promise<V> supplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier, long delayTicks)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the supplier
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayed

      @NotNull default @NotNull Promise<V> supplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      supplier - the supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayedSync

      @NotNull @NotNull Promise<V> supplyDelayedSync(@NotNull @NotNull Supplier<V> supplier, long delayTicks)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      supplier - the supplier
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayedSync

      @NotNull @NotNull Promise<V> supplyDelayedSync(@NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      supplier - the supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayedAsync

      @NotNull @NotNull Promise<V> supplyDelayedAsync(@NotNull @NotNull Supplier<V> supplier, long delayTicks)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      supplier - the supplier
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyDelayedAsync

      @NotNull @NotNull Promise<V> supplyDelayedAsync(@NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.
      Parameters:
      supplier - the supplier
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionally

      @NotNull default @NotNull Promise<V> supplyExceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable)
      Schedules the supply of the Promise's result, via the given callable.
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the callable
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallySync

      @NotNull @NotNull Promise<V> supplyExceptionallySync(@NotNull @NotNull Callable<V> callable)
      Schedules the supply of the Promise's result, via the given callable.
      Parameters:
      callable - the callable
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyAsync

      @NotNull @NotNull Promise<V> supplyExceptionallyAsync(@NotNull @NotNull Callable<V> callable)
      Schedules the supply of the Promise's result, via the given callable.
      Parameters:
      callable - the callable
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayed

      @NotNull default @NotNull Promise<V> supplyExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable, long delayTicks)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the callable
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayed

      @NotNull default @NotNull Promise<V> supplyExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      callable - the callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayedSync

      @NotNull @NotNull Promise<V> supplyExceptionallyDelayedSync(@NotNull @NotNull Callable<V> callable, long delayTicks)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      callable - the callable
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayedSync

      @NotNull @NotNull Promise<V> supplyExceptionallyDelayedSync(@NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      callable - the callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayedAsync

      @NotNull @NotNull Promise<V> supplyExceptionallyDelayedAsync(@NotNull @NotNull Callable<V> callable, long delayTicks)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      callable - the callable
      delayTicks - the delay in ticks
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • supplyExceptionallyDelayedAsync

      @NotNull @NotNull Promise<V> supplyExceptionallyDelayedAsync(@NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit)
      Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.
      Parameters:
      callable - the callable
      delay - the delay
      unit - the unit of delay
      Returns:
      the same promise
      Throws:
      IllegalStateException - if the promise is already being supplied, or has already been completed.
    • thenApply

      @NotNull default <U> @NotNull Promise<U> thenApply(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends U> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenApplySync

      @NotNull <U> @NotNull Promise<U> thenApplySync(@NotNull @NotNull Function<? super V,? extends U> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenApplyAsync

      @NotNull <U> @NotNull Promise<U> thenApplyAsync(@NotNull @NotNull Function<? super V,? extends U> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenApplyDelayed

      @NotNull default <U> @NotNull Promise<U> thenApplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends U> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenApplyDelayed

      @NotNull default <U> @NotNull Promise<U> thenApplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenApplyDelayedSync

      @NotNull <U> @NotNull Promise<U> thenApplyDelayedSync(@NotNull @NotNull Function<? super V,? extends U> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenApplyDelayedSync

      @NotNull <U> @NotNull Promise<U> thenApplyDelayedSync(@NotNull @NotNull Function<? super V,? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenApplyDelayedAsync

      @NotNull <U> @NotNull Promise<U> thenApplyDelayedAsync(@NotNull @NotNull Function<? super V,? extends U> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenApplyDelayedAsync

      @NotNull <U> @NotNull Promise<U> thenApplyDelayedAsync(@NotNull @NotNull Function<? super V,? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenAccept

      @NotNull default @NotNull Promise<Void> thenAccept(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to perform before completing the returned future
      Returns:
      the new promise
    • thenAcceptSync

      @NotNull default @NotNull Promise<Void> thenAcceptSync(@NotNull @NotNull Consumer<? super V> action)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
      Parameters:
      action - the action to perform before completing the returned future
      Returns:
      the new promise
    • thenAcceptAsync

      @NotNull default @NotNull Promise<Void> thenAcceptAsync(@NotNull @NotNull Consumer<? super V> action)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.
      Parameters:
      action - the action to perform before completing the returned future
      Returns:
      the new promise
    • thenAcceptDelayed

      @NotNull default @NotNull Promise<Void> thenAcceptDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to perform before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenAcceptDelayed

      @NotNull default @NotNull Promise<Void> thenAcceptDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to perform before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenAcceptDelayedSync

      @NotNull default @NotNull Promise<Void> thenAcceptDelayedSync(@NotNull @NotNull Consumer<? super V> action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      action - the action to perform before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenAcceptDelayedSync

      @NotNull default @NotNull Promise<Void> thenAcceptDelayedSync(@NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      action - the action to perform before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenAcceptDelayedAsync

      @NotNull default @NotNull Promise<Void> thenAcceptDelayedAsync(@NotNull @NotNull Consumer<? super V> action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      action - the action to perform before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenAcceptDelayedAsync

      @NotNull default @NotNull Promise<Void> thenAcceptDelayedAsync(@NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.
      Parameters:
      action - the action to perform before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenRun

      @NotNull default @NotNull Promise<Void> thenRun(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action)
      Returns a new Promise that, when this promise completes normally, executes the given task.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to run before completing the returned future
      Returns:
      the new promise
    • thenRunSync

      @NotNull default @NotNull Promise<Void> thenRunSync(@NotNull @NotNull Runnable action)
      Returns a new Promise that, when this promise completes normally, executes the given task.
      Parameters:
      action - the action to run before completing the returned future
      Returns:
      the new promise
    • thenRunAsync

      @NotNull default @NotNull Promise<Void> thenRunAsync(@NotNull @NotNull Runnable action)
      Returns a new Promise that, when this promise completes normally, executes the given task.
      Parameters:
      action - the action to run before completing the returned future
      Returns:
      the new promise
    • thenRunDelayed

      @NotNull default @NotNull Promise<Void> thenRunDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to run before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenRunDelayed

      @NotNull default @NotNull Promise<Void> thenRunDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      context - the type of executor to use to supply the promise
      action - the action to run before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenRunDelayedSync

      @NotNull default @NotNull Promise<Void> thenRunDelayedSync(@NotNull @NotNull Runnable action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      action - the action to run before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenRunDelayedSync

      @NotNull default @NotNull Promise<Void> thenRunDelayedSync(@NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      action - the action to run before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenRunDelayedAsync

      @NotNull default @NotNull Promise<Void> thenRunDelayedAsync(@NotNull @NotNull Runnable action, long delayTicks)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      action - the action to run before completing the returned future
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenRunDelayedAsync

      @NotNull default @NotNull Promise<Void> thenRunDelayedAsync(@NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.
      Parameters:
      action - the action to run before completing the returned future
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenCompose

      @NotNull default <U> @NotNull Promise<U> thenCompose(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends Promise<U>> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenComposeSync

      @NotNull <U> @NotNull Promise<U> thenComposeSync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenComposeAsync

      @NotNull <U> @NotNull Promise<U> thenComposeAsync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      Returns:
      the new promise
    • thenComposeDelayedSync

      @NotNull default <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenComposeDelayedSync

      @NotNull default <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenComposeDelayedSync

      @NotNull <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenComposeDelayedSync

      @NotNull <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • thenComposeDelayedAsync

      @NotNull <U> @NotNull Promise<U> thenComposeDelayedAsync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • thenComposeDelayedAsync

      @NotNull <U> @NotNull Promise<U> thenComposeDelayedAsync(@NotNull @NotNull Function<? super V,? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.
      Type Parameters:
      U - the result type
      Parameters:
      fn - the function to use to compute the value
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • exceptionally

      @NotNull default @NotNull Promise<V> exceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable,? extends V> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      Returns:
      the new promise
    • exceptionallySync

      @NotNull @NotNull Promise<V> exceptionallySync(@NotNull @NotNull Function<Throwable,? extends V> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      Returns:
      the new promise
    • exceptionallyAsync

      @NotNull @NotNull Promise<V> exceptionallyAsync(@NotNull @NotNull Function<Throwable,? extends V> fn)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      Returns:
      the new promise
    • exceptionallyDelayed

      @NotNull default @NotNull Promise<V> exceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable,? extends V> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • exceptionallyDelayed

      @NotNull default @NotNull Promise<V> exceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable,? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      context - the type of executor to use to supply the promise
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • exceptionallyDelayedSync

      @NotNull @NotNull Promise<V> exceptionallyDelayedSync(@NotNull @NotNull Function<Throwable,? extends V> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • exceptionallyDelayedSync

      @NotNull @NotNull Promise<V> exceptionallyDelayedSync(@NotNull @NotNull Function<Throwable,? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • exceptionallyDelayedAsync

      @NotNull @NotNull Promise<V> exceptionallyDelayedAsync(@NotNull @NotNull Function<Throwable,? extends V> fn, long delayTicks)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delayTicks - the delay in ticks
      Returns:
      the new promise
    • exceptionallyDelayedAsync

      @NotNull @NotNull Promise<V> exceptionallyDelayedAsync(@NotNull @NotNull Function<Throwable,? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit)
      Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.
      Parameters:
      fn - the function to use to compute the value of the returned Promise, if this promise completed exceptionally
      delay - the delay
      unit - the unit of delay
      Returns:
      the new promise
    • toCompletableFuture

      CompletableFuture<V> toCompletableFuture()
      Returns a CompletableFuture maintaining the same completion properties as this Promise.

      A Promise implementation that does not choose to interoperate with CompletableFutures may throw UnsupportedOperationException.

      Returns:
      the CompletableFuture
      Throws:
      UnsupportedOperationException - if this implementation does not interoperate with CompletableFuture