Package kotlinx.coroutines.future

Integration with JDK8 CompletableFuture (Android API level 24).

Functions

asCompletableFuture
Link copied to clipboard
fun <T> Deferred<T>.asCompletableFuture(): CompletableFuture<T>

Converts this deferred value to the instance of CompletableFuture. The deferred value is cancelled when the resulting future is cancelled or otherwise completed.

fun Job.asCompletableFuture(): CompletableFuture<Unit>

Converts this job to the instance of CompletableFuture. The job is cancelled when the resulting future is cancelled or otherwise completed.

asDeferred
Link copied to clipboard
fun <T> CompletionStage<T>.asDeferred(): Deferred<T>

Converts this CompletionStage to an instance of Deferred.

await
Link copied to clipboard
suspend fun <T> CompletionStage<T>.await(): T

Awaits for completion of CompletionStage without blocking a thread.

future
Link copied to clipboard
fun <T> CoroutineScope.future(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): CompletableFuture<T>

Starts a new coroutine and returns its result as an implementation of CompletableFuture. The running coroutine is cancelled when the resulting future is cancelled or otherwise completed.