public CompletableDeferred<T> extends Deferred<T>
A interface Deferred
that can be completed via public functions CompletableDeferred.complete
or Job.cancel
.
Note, that CompletableDeferred.complete
functions returns false
when this deferred value is already complete or completing,
while Job.cancel
returns true
as long the deferred is still cancelling and the corresponding
exception is incorporated into the final Deferred.getCompletionExceptionOrNull
.
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.
Job.DefaultImpls, Job.Key
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
cancel, getChildren, getOnJoin, 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
.