Hello,
I have a question regarding the actors
of kotlinx.coroutines
:
Suppose I have a actor like
val act = actor<String>(capacity = Channel.UNLIMITED) {
for (msg in channel) when(msg) {
"delay" -> delay(5000L)
"print" -> println("print")
}
}
I now execute
act.offer("delay")
act.offer("print")
What will happen?
Does println
print immediately or after 5 seconds?
→ Does a suspending call (job.await()
, delay
, yield
etc) in the message loop blocks the channel until completed or not?
Sorry if this is simple/silly question, I cannot put my head around this.