Class CallbackCompletable<T>

java.lang.Object
ca.spottedleaf.concurrentutil.completable.CallbackCompletable<T>

public final class CallbackCompletable<T> extends Object
  • Constructor Details

    • CallbackCompletable

      public CallbackCompletable()
  • Method Details

    • isCompleted

      public boolean isCompleted()
    • getResult

      public T getResult()
      Note: Can only use after calling addAsynchronousWaiter(BiConsumer), as this function performs zero synchronisation
    • getThrowable

      public Throwable getThrowable()
      Note: Can only use after calling addAsynchronousWaiter(BiConsumer), as this function performs zero synchronisation
    • addAsynchronousWaiter

      public Cancellable addAsynchronousWaiter(BiConsumer<T,Throwable> consumer)
      Adds a waiter that should only be completed asynchronously by the complete() calls. If complete() has already been called, returns null and does not invoke the specified consumer.
      Parameters:
      consumer - Consumer to be executed on completion
      Returns:
      A cancellable which will control the execution of the specified consumer
      Throws:
      NullPointerException - If consumer is null
    • addWaiter

      public Cancellable addWaiter(BiConsumer<T,Throwable> consumer)
      Adds a waiter that will be completed asynchronously by the complete() calls. If complete() has already been called, then invokes the consumer synchronously with the completed result.
      Parameters:
      consumer - Consumer to be executed on completion
      Returns:
      A cancellable which will control the execution of the specified consumer
      Throws:
      NullPointerException - If consumer is null
    • complete

      public void complete(T result)
    • completeWithThrowable

      public void completeWithThrowable(Throwable throwable)