mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
Move coroutine intrinsics to kotlin.coroutine.intrinsics package
Also rename val SUSPENDED to SUSPENDED_MARKER #KT-15698 Fixed
This commit is contained in:
5
compiler/testData/codegen/java8/box/async.kt
vendored
5
compiler/testData/codegen/java8/box/async.kt
vendored
@@ -3,6 +3,7 @@
|
||||
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun foo(): CompletableFuture<String> = CompletableFuture.supplyAsync { "foo" }
|
||||
fun bar(v: String): CompletableFuture<String> = CompletableFuture.supplyAsync { "bar with $v" }
|
||||
@@ -58,12 +59,12 @@ fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
||||
return future
|
||||
}
|
||||
|
||||
suspend fun <V> await(f: CompletableFuture<V>) = CoroutineIntrinsics.suspendCoroutineOrReturn<V> { machine ->
|
||||
suspend fun <V> await(f: CompletableFuture<V>) = suspendCoroutineOrReturn<V> { machine ->
|
||||
f.whenComplete { value, throwable ->
|
||||
if (throwable == null)
|
||||
machine.resume(value)
|
||||
else
|
||||
machine.resumeWithException(throwable)
|
||||
}
|
||||
CoroutineIntrinsics.SUSPENDED
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun exception(v: String): CompletableFuture<String> = CompletableFuture.supplyAsync { throw RuntimeException(v) }
|
||||
|
||||
@@ -55,12 +56,12 @@ fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
||||
return future
|
||||
}
|
||||
|
||||
suspend fun <V> await(f: CompletableFuture<V>) = CoroutineIntrinsics.suspendCoroutineOrReturn<V> { machine ->
|
||||
suspend fun <V> await(f: CompletableFuture<V>) = suspendCoroutineOrReturn<V> { machine ->
|
||||
f.whenComplete { value, throwable ->
|
||||
if (throwable == null)
|
||||
machine.resume(value)
|
||||
else
|
||||
machine.resumeWithException(throwable)
|
||||
}
|
||||
CoroutineIntrinsics.SUSPENDED
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user