Remove sleep() from soSuspendableCallInEndOfFun and guarantee suspending
This commit is contained in:
+5
-2
@@ -1,19 +1,22 @@
|
||||
package soSuspendableCallInEndOfFun
|
||||
|
||||
import forTests.builder
|
||||
import forTests.WaitFinish
|
||||
import forTests.builder
|
||||
import kotlin.coroutines.experimental.Continuation
|
||||
import kotlin.coroutines.experimental.suspendCoroutine
|
||||
|
||||
private fun foo(a: Any) {}
|
||||
|
||||
val waiter = WaitFinish()
|
||||
val suspendWaiter = WaitFinish()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
builder {
|
||||
inFun()
|
||||
}
|
||||
|
||||
suspendWaiter.finish()
|
||||
|
||||
foo("Main end")
|
||||
waiter.waitEnd()
|
||||
}
|
||||
@@ -27,7 +30,7 @@ suspend fun inFun() {
|
||||
suspend fun run() {
|
||||
suspendCoroutine { cont: Continuation<Unit> ->
|
||||
Thread {
|
||||
Thread.sleep(10)
|
||||
suspendWaiter.waitEnd()
|
||||
cont.resume(Unit)
|
||||
waiter.finish()
|
||||
}.start()
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
LineBreakpoint created at soSuspendableCallInEndOfFun.kt:24
|
||||
LineBreakpoint created at soSuspendableCallInEndOfFun.kt:27
|
||||
Run Java
|
||||
Connected to the target VM
|
||||
soSuspendableCallInEndOfFun.kt:24
|
||||
soSuspendableCallInEndOfFun.kt:21
|
||||
soSuspendableCallInEndOfFun.kt:25
|
||||
soSuspendableCallInEndOfFun.kt:-1
|
||||
soSuspendableCallInEndOfFun.kt:32
|
||||
soSuspendableCallInEndOfFun.kt:27
|
||||
soSuspendableCallInEndOfFun.kt:15
|
||||
soSuspendableCallInEndOfFun.kt:14
|
||||
soSuspendableCallInEndOfFun.kt:16
|
||||
soSuspendableCallInEndOfFun.kt:35
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
|
||||
Reference in New Issue
Block a user