Chris Grigg
05/03/2021, 2:59 PMlaunch
from your existing context and then move it elsewhere using withContext
instead of calling launch
and specifying dispatcher. scope.launch { withContext(<http://Dispatchers.IO|Dispatchers.IO>) { work() } }
instead of scope.launch(<http://Dispatchers.IO|Dispatchers.IO>) { work() }
. I remember this being described as preferential since there was some performance penalty when launching in a different context that did not occur when moving a running coroutine using withContext
. I’m trying to find guidance on this again and I can’t find anything about it. Did I misunderstand something when I was first learning?Zach Klippenstein (he/him) [MOD]
05/03/2021, 3:22 PMChris Grigg
05/03/2021, 3:26 PMFrancesc
05/03/2021, 3:42 PMDefault
and IO
which share a common thread pool and switching between those may not do an actual thread switchuli
05/04/2021, 6:02 AMChris Grigg
05/05/2021, 2:00 PM