-
- All Known Implementing Classes:
Sync
public interface Cont<T>Continuation of an asynchronous operation. Thebind(T)method gets called when the asynchronous operation completes with a value; thetrap(Throwable)method gets called when the asynchronous operation fails with an exception.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T> Runnableasync(Cont<T> cont, T value)Returns aRunnablethat, when executed, invokes the givencontinuation with the provided constantvalue.voidbind(T value)Invoked when the asynchronous operation completes with avalue.static <X,T>
Cont<X>constant(Cont<T> cont, T value)Returns aContinuation that, when completed successfully, completes the givencontinuation with the provided constantvalue; and when failed with an error, fails the givencontinuation with the error.static <T> Cont<T>ignore()Returns aContcontinuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.static booleanisNonFatal(Throwable throwable)Returnstrueifthrowableis a recoverable exception; returnsfalseifthrowablecannot be recovered from.voidtrap(Throwable error)Invoked when the asynchronous operation fails with anerror.
-
-
-
Method Detail
-
bind
void bind(T value)
Invoked when the asynchronous operation completes with avalue.
-
trap
void trap(Throwable error)
Invoked when the asynchronous operation fails with anerror.
-
async
static <T> Runnable async(Cont<T> cont, T value)
Returns aRunnablethat, when executed, invokes the givencontinuation with the provided constantvalue.
-
constant
static <X,T> Cont<X> constant(Cont<T> cont, T value)
Returns aContinuation that, when completed successfully, completes the givencontinuation with the provided constantvalue; and when failed with an error, fails the givencontinuation with the error.
-
ignore
static <T> Cont<T> ignore()
Returns aContcontinuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.
-
isNonFatal
static boolean isNonFatal(Throwable throwable)
Returnstrueifthrowableis a recoverable exception; returnsfalseifthrowablecannot be recovered from.
-
-