await

suspend fun <T> CompletionStage<T>.await(): T

Awaits for completion of the completion stage without blocking a thread.

This suspending function is cancellable. If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function stops waiting for the completion stage and immediately resumes with CancellationException. This method is intended to be used with one-shot futures, so on coroutine cancellation completion stage is cancelled as well if it is instance of CompletableFuture. If cancelling given stage is undesired, stage.asDeferred().await() should be used instead.