Interface Cont<T>

All Known Subinterfaces:
Call<T>, Stay<T>
All Known Implementing Classes:
Sync

public interface Cont<T>
Continuation of an asynchronous operation. The bind(T) method gets called when the asynchronous operation completes with a value; the trap(Throwable) method gets called when the asynchronous operation fails with an exception.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Runnable
    async(Cont<T> cont, T value)
    Returns a Runnable that, when executed, invokes the given continuation with the provided constant value.
    void
    bind(T value)
    Invoked when the asynchronous operation completes with a value.
    static <X, T> Cont<X>
    constant(Cont<T> cont, T value)
    Returns a Continuation that, when completed successfully, completes the given continuation with the provided constant value; and when failed with an error, fails the given continuation with the error.
    static <T> Cont<T>
    Returns a Cont continuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.
    static boolean
    isNonFatal(Throwable throwable)
    Returns true if throwable is a recoverable exception; returns false if throwable cannot be recovered from.
    void
    trap(Throwable error)
    Invoked when the asynchronous operation fails with an error.
  • Method Details

    • bind

      void bind(T value)
      Invoked when the asynchronous operation completes with a value.
    • trap

      void trap(Throwable error)
      Invoked when the asynchronous operation fails with an error.
    • async

      static <T> Runnable async(Cont<T> cont, T value)
      Returns a Runnable that, when executed, invokes the given continuation with the provided constant value.
    • constant

      static <X, T> Cont<X> constant(Cont<T> cont, T value)
      Returns a Continuation that, when completed successfully, completes the given continuation with the provided constant value; and when failed with an error, fails the given continuation with the error.
    • ignore

      static <T> Cont<T> ignore()
      Returns a Cont continuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.
    • isNonFatal

      static boolean isNonFatal(Throwable throwable)
      Returns true if throwable is a recoverable exception; returns false if throwable cannot be recovered from.