vaskir
06/14/2017, 8:03 PMfun main(args: Array<String>) = runBlocking {
val ch = Channel<Unit>()
launch(CommonPool) {
select<Unit> {
ch.onReceive {
println("0")
launch(CommonPool) {
println("1")
ch.onReceive {
println("2")
ch.onReceive { println("3") }
}
}
}
}
}
repeat(10) { ch.send(Unit) }
}
output
0
1
So all onReceive
belong to the select
and I think they should be prohibited in (some kinds of?) nested scopes. Does it make sense or I'm missing something?