Joris PZ
11/21/2018, 7:11 AMsuspend fun functionA() {
// A1
functionB()
// A2
}
suspend fun functionB() {
// B1
delay(1000)
// B2
}
where A1, A2 etc denote normal, non-suspending code blocks. I'm trying to understand how these code blocks are scheduled on the available threads.
Suppose functionA is currently executing on some thread T1, using a dispatcher that has multiple threads available. The call to functionB is a suspension point - is it correct to say that at that point, executing of my code may be suspended to allow some other work to be done on T1? In that case, does that also mean that B1 can be scheduled on a different thread?
I'm pretty sure this happens around the call to delay, but I'm uncertain about my own code.
Similarly, what about B2 and A2? Are they guaranteed to be executed on the same thread, or is exiting a suspending function also a suspend point?elizarov
11/21/2018, 7:36 AMJoris PZ
11/21/2018, 7:46 AM