corda / net.corda.core.concurrent / CordaFuture

CordaFuture

interface CordaFuture<V> : Future<V>

Same as Future with additional methods to provide some of the features of java.util.concurrent.CompletableFuture while minimising the API surface area. In Kotlin, to avoid compile errors, whenever CordaFuture is used in a parameter or extension method receiver type, its type parameter should be specified with out variance.

Functions

then

abstract fun <W> then(callback: (CordaFuture<V>) -> W): Unit

Run the given callback when this future is done, on the completion thread. If the completion thread is problematic for you e.g. deadlock, you can submit to an executor manually. If callback fails, its throwable is logged.

toCompletableFuture

abstract fun toCompletableFuture(): CompletableFuture<V>

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.

getOrThrow

fun <V> Future<V>.getOrThrow(timeout: Duration? = null): V

Same as Future.get except that the ExecutionException is unwrapped.

match

fun <V, W> Future<V>.match(success: (V) -> W, failure: (Throwable) -> W): W

Invoke getOrThrow and pass the value/throwable to success/failure respectively.

toObservable

fun <A> CordaFuture<out A>.toObservable(): Observable<A>