dimsuz
09/10/2021, 10:13 PMwithContext
?
suspend fun callMe() {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
doAllWorkHere()
}
}
If withContext
is not used then I risk that the caller will use a context which is bad for this particular workload.
Or is there some other well established pattern or design consideration for such cases?Joffrey
09/10/2021, 10:18 PMsuspend
function internally uses the appropriate IO context in that case.
For reference: https://elizarov.medium.com/blocking-threads-suspending-coroutines-d33e11bf4761ephemient
09/10/2021, 10:19 PMJoffrey
09/10/2021, 10:20 PMcoroutineContext
as argument, which defaults to <http://Dispatchers.IO|Dispatchers.IO>
.dimsuz
09/10/2021, 10:39 PM