Slide 18
Slide 18 text
ステートマシン
デコンパイルした中身を擬似コード化
1. mainのLaunchの中身が実行される
fun printWorld(continue: Continuation) {
val cont = ContinuationImpl() {
fun invokeSuspend() {
printWorld()
}
}
switch(continue.label){
0:
label = 1
if(Delayed(1000, cont) == suspend)
return suspend
break;
1:
throwOnFailure
2:
ThrowIllegalState
}
println(“world")
}
// EventLoop
// Default label = 0
fun main() {
runBlocking {
launch {
switch(label){
0:
label = 1
if(printWorld(this) == suspend)
return suspend
break;
1:
throwOnFailure
2:
ThrowIllegalState
}
}
println("Hello")
}
}