public CompletableDeferred<T> extends Deferred<T>
A interface Deferred
that can be completed via public functions
CompletableDeferred.complete
, CompletableDeferred.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.
Deferred.DefaultImpls
Modifier and Type | Method and Description |
---|---|
boolean |
complete(T value)
Completes this deferred value with a given value. The result is
true if this deferred was
completed as a result of this invocation and false otherwise (if it was already completed). |
boolean |
completeExceptionally(java.lang.Throwable exception)
Completes this deferred value exceptionally with a given exception. The result is
true if this deferred was
completed as a result of this invocation and false otherwise (if it was already completed). |
await, getCompleted, getCompletionExceptionOrNull, getOnAwait, isCompletedExceptionally
cancel, getCancellationException, getChildren, getOnJoin, invokeOnCompletion, invokeOnCompletion, isActive, isCancelled, isCompleted, join, start
boolean complete(T value)
Completes this deferred value with a given value. The result is true
if this deferred was
completed as a result of this invocation and false
otherwise (if it was already completed).
Repeated invocations of this function have no effect and always produce false
.
boolean completeExceptionally(java.lang.Throwable exception)
Completes this deferred value exceptionally with a given exception. The result is true
if this deferred was
completed as a result of this invocation and false
otherwise (if it was already completed).
Repeated invocations of this function have no effect and always produce false
.