Aaron Todd
11/17/2020, 7:50 PM1 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)Zach Klippenstein (he/him) [MOD]
11/17/2020, 8:06 PMAaron Todd
11/17/2020, 8:59 PM