-
- 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> Runnable
async(Cont<T> cont, T value)
Returns aRunnable
that, when executed, invokes the givencont
inuation with the provided constantvalue
.void
bind(T value)
Invoked when the asynchronous operation completes with avalue
.static <X,T>
Cont<X>constant(Cont<T> cont, T value)
Returns aCont
inuation that, when completed successfully, completes the givencont
inuation with the provided constantvalue
; and when failed with an error, fails the givencont
inuation with the error.static <T> Cont<T>
ignore()
Returns aCont
continuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.static boolean
isNonFatal(Throwable throwable)
Returnstrue
ifthrowable
is a recoverable exception; returnsfalse
ifthrowable
cannot be recovered from.void
trap(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 aRunnable
that, when executed, invokes the givencont
inuation with the provided constantvalue
.
-
constant
static <X,T> Cont<X> constant(Cont<T> cont, T value)
Returns aCont
inuation that, when completed successfully, completes the givencont
inuation with the provided constantvalue
; and when failed with an error, fails the givencont
inuation with the error.
-
ignore
static <T> Cont<T> ignore()
Returns aCont
continuation that, when completed successfully, does nothing; and when failed with an exception, throws the exception.
-
isNonFatal
static boolean isNonFatal(Throwable throwable)
Returnstrue
ifthrowable
is a recoverable exception; returnsfalse
ifthrowable
cannot be recovered from.
-
-