if I have a background/worker coroutine that is pr...
# coroutines
a
if I have a background/worker coroutine that is processing tasks like so
Copy code
1 suspend fun processTasks(chan: ReceiveChannel<MyTask>) {
2    for(task in chan) {
3        doWork() // non-suspend function
4    }
5 }
is it correct to say that on Line 3 once the coroutine is running on a thread it will not suspend again and potentially switch threads until the next call to
chan.receive()
on line 2? More generically the only time a coroutine has a chance to suspend is at a suspension point which is defined by a
suspend
function call? (i.e. no instruction level suspension possible)
z
yep
a
thanks, that was my understanding but sometimes you have to do a double check