CompletableDeferred
A Deferred that can be completed via public functions complete, completeExceptionally, and cancel.
Completion functions return false
when this deferred value is already complete or completing.
An instance of completable deferred can be created by CompletableDeferred()
function in active state.
All functions on this interface and on all interfaces derived from it are thread-safe and can be safely invoked from concurrent coroutines without external synchronization.
Inherited Properties
abstract val isCompletedExceptionally: Boolean Returns |
|
abstract val onAwait: SelectClause1<T> Clause for select expression of await suspending function that selects with the deferred value when it is resolved. The select invocation fails if the deferred value completes exceptionally (either fails or it cancelled). |
Functions
Completes this deferred value with a given value. The result is |
|
Completes this deferred value exceptionally with a given exception. The result is |
Inherited Functions
abstract suspend fun await(): T Awaits for completion of this value without blocking a thread and resumes when deferred computation is complete, returning the resulting value or throwing the corresponding exception if the deferred had completed exceptionally. |
|
abstract fun getCompleted(): T Returns completed result or throws IllegalStateException if this deferred value has not completed yet. It throws the corresponding exception if this deferred has completed exceptionally. |
|
abstract fun getCompletionExceptionOrNull(): Throwable? Returns completion exception result if this deferred completed exceptionally,
|
Extension Functions
Converts this deferred value to the instance of Promise. |
|
fun CoroutineContext.cancel( Cancels Job of this context with an optional cancellation cause. The result is |
|
Cancels the job and suspends invoking coroutine until the cancelled job is complete. |
|
fun Job.cancelFutureOnCompletion( Cancels a specified future when this job is complete. |
|
fun Job.disposeOnCompletion( Disposes a specified handle when this job is complete. |
|
Suspends coroutine until all children of this job are complete using Job.join for all of them. Unlike Job.join on this job as a whole, it does not wait until this job is complete. |