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
Copy file name to clipboardExpand all lines: integration/kotlinx-coroutines-jdk8/api/kotlinx-coroutines-jdk8.api
+2
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
public final class kotlinx/coroutines/future/FutureKt {
2
2
public static final fun asCompletableFuture (Lkotlinx/coroutines/Deferred;)Ljava/util/concurrent/CompletableFuture;
3
3
public static final fun asCompletableFuture (Lkotlinx/coroutines/Job;)Ljava/util/concurrent/CompletableFuture;
4
+
public static final fun asDeferred (Ljava/util/concurrent/CompletableFuture;)Lkotlinx/coroutines/Deferred;
4
5
public static final fun asDeferred (Ljava/util/concurrent/CompletionStage;)Lkotlinx/coroutines/Deferred;
6
+
public static final fun await (Ljava/util/concurrent/CompletableFuture;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5
7
public static final fun await (Ljava/util/concurrent/CompletionStage;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
6
8
public static final fun future (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/CoroutineStart;Lkotlin/jvm/functions/Function2;)Ljava/util/concurrent/CompletableFuture;
7
9
public static synthetic fun future$default (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/CoroutineStart;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/util/concurrent/CompletableFuture;
* Awaits for completion of [CompletionStage] without blocking a thread.
141
166
*
142
167
* This suspending function is cancellable.
143
168
* If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
144
169
* 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].
170
+
* 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 a [Future].
146
171
* If cancelling given stage is undesired, `stage.asDeferred().await()` should be used instead.
172
+
*
173
+
* ### Implementation details
174
+
*
175
+
* [CompletionStage] does not extend a [Future] and does not provide future-like methods to check for completion and
176
+
* to retrieve a resulting value, so this implementation always takes a slow path of installing a callback with
177
+
* [CompletionStage.whenComplete]. For cases when [CompletionStage] is statically known to be an instance
178
+
* of [CompletableFuture] there is an overload of this `await` function with a [CompletableFuture] receiver that
179
+
* has a fast-path for a future that is already complete. Note, that it is not safe to dynamically check if an instance
180
+
* of a [CompletionStage] is an instance of a [CompletableFuture], because JDK functions return instances that do
181
+
* implement a [CompletableFuture], yet throw an exception on most of the future-like methods in it.
182
+
* For the purpose of cancelling the the future, the corresponding [UnsupportedOperationException] is ignored in this case.
147
183
*/
148
-
publicsuspendfun <T> CompletionStage<T>.await(): T {
0 commit comments