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