You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (thisisFuture<*>) result.cancelFutureOnCompletion(this)
138
+
result.cancelFutureOnCompletion(future)
136
139
return result
137
140
}
138
141
139
142
/**
140
-
* Awaits for completion of the completion stage without blocking a thread.
143
+
* Awaits for completion of [CompletionStage] without blocking a thread.
141
144
*
142
145
* This suspending function is cancellable.
143
146
* If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
144
147
* stops waiting for the completion stage and immediately resumes with [CancellationException][kotlinx.coroutines.CancellationException].
145
-
* 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].
146
-
* If cancelling given stage is undesired, `stage.asDeferred().await()` should be used instead.
148
+
*
149
+
* This method is intended to be used with one-shot futures, so on coroutine cancellation the [CompletableFuture] that
150
+
* corresponds to this [CompletionStage] (see [CompletionStage.toCompletableFuture])
151
+
* is cancelled. If cancelling the given stage is undesired, `stage.asDeferred().await()` should be used instead.
147
152
*/
148
153
publicsuspendfun <T> CompletionStage<T>.await(): T {
154
+
val future = toCompletableFuture() // retrieve the future
149
155
// fast path when CompletableFuture is already done (does not suspend)
0 commit comments