Pritam Kadam
09/16/2020, 12:13 PMDispatchers.Default
or create separate scope with fixed thread pools equal to number of cores?
what are the pros and cons? what are the criteria's to choose between one of this approach? for ex. Library writer, App writer etc.
I have posted detailed explanation and my use cases here https://stackoverflow.com/questions/63915078/can-i-use-dispatchers-default-for-blocking-cpu-bound-operationslouiscad
09/16/2020, 12:17 PMDispatchers.Default
, it answers your question, telling that it's designed for that.Pritam Kadam
09/16/2020, 1:30 PMDefault
etc.louiscad
09/16/2020, 1:32 PMexitProcess()
or System.exit()
. In all cases, it needs to be fixed.Pritam Kadam
09/16/2020, 1:33 PMDefault
dispatcher, but we are having debate within the team, hence the questionlouiscad
09/16/2020, 1:37 PMI hope, you have read my stackoverflow questionI did not because the answer to the title was "yes".
Pritam Kadam
09/16/2020, 1:38 PMlouiscad
09/16/2020, 1:39 PM<http://Dispatchers.IO|Dispatchers.IO>
).Pritam Kadam
09/16/2020, 1:40 PMrocketraman
09/16/2020, 1:40 PMlouiscad
09/16/2020, 1:40 PMPritam Kadam
09/16/2020, 1:41 PMlouiscad
09/16/2020, 1:41 PMDispatchers.Default
.rocketraman
09/16/2020, 1:42 PMPritam Kadam
09/16/2020, 1:43 PMlouiscad
09/16/2020, 1:44 PMrocketraman
09/16/2020, 1:45 PMlouiscad
09/16/2020, 1:46 PMrocketraman
09/16/2020, 1:46 PMPritam Kadam
09/16/2020, 1:47 PMdefault/global are meant for cpu bound operations because they follow no of threads roughly equals to no of cores
having another thread pool will not solve a problem if there are 8 CPU bound operations already running and you want to start 9th operation (that will have to wait) (here assumption is, machine has 8 cpu cores)
rocketraman
09/16/2020, 1:48 PMPritam Kadam
09/16/2020, 1:50 PMCPU Intensive
to avoid confusionTrue isolation is process isolation, and even that has limits.
rocketraman
09/16/2020, 1:56 PMlouiscad
09/16/2020, 1:57 PMDispatchers.Default
instead of <http://Dispatchers.IO|Dispatchers.IO>
or something else in the same process of your library.rocketraman
09/16/2020, 1:58 PMlouiscad
09/16/2020, 1:59 PMPritam Kadam
09/16/2020, 1:59 PMlouiscad
09/16/2020, 2:00 PMrocketraman
09/16/2020, 2:03 PMyield
between the chunks to give other coroutines the ability to run. It'd be interesting to see if that worked well enough to avoid the need for process isolation.Pritam Kadam
09/16/2020, 2:04 PM2. As it is available globally, anyone could have used it in 3rd party libs for doing IO
though we should not be using lib with such quality but its hard to find out ;)
(this is fine as long as they are doing cpu ops)
rocketraman
09/16/2020, 2:09 PMwithContext
but more limited to the options you want to give them.Pritam Kadam
09/16/2020, 2:10 PMrocketraman
09/16/2020, 2:12 PMPritam Kadam
09/16/2020, 2:14 PMwithContext(Dispatchers.Default)
for cpu bound task and call that function from scriptrocketraman
09/16/2020, 2:15 PMPritam Kadam
09/16/2020, 2:16 PMrocketraman
09/16/2020, 2:22 PMPritam Kadam
09/16/2020, 2:24 PMrocketraman
09/16/2020, 2:24 PMPritam Kadam
09/16/2020, 2:26 PM