vineethraj49
04/05/2021, 5:42 PMTwoClocks
04/05/2021, 5:49 PMkotlinx.coroutines.scheduling.DefaultScheduler
Looks like what you want.
At a casual glance it looks like it pre-allocated the # of threads (caped to 64 or the # of processors you have).
Then dispatches to a thread from that pool... or waits until one is available.TwoClocks
04/05/2021, 5:51 PMkevin.cianfarini
04/05/2021, 6:40 PMTwoClocks
04/05/2021, 6:53 PMCasey Brooks
04/05/2021, 9:39 PMTwoClocks
04/06/2021, 12:25 AMTwoClocks
04/06/2021, 12:26 AMAlex Vasilkov
04/06/2021, 4:32 AMursus
04/06/2021, 10:04 AMAlex Vasilkov
04/06/2021, 10:20 AM<http://java.io|java.io>.*
API for IO operations in Kotlin and it is blocking. There is java.nio.*
API, but I don’t think it is widely used yet. For example on Android nio files are supported only starting from SDK 26.ursus
04/06/2021, 10:40 AMAlex Vasilkov
04/06/2021, 10:44 AM<http://Dispatchers.IO|Dispatchers.IO>
pool instead of Dispatchers.Default
.ursus
04/06/2021, 10:45 AMAlex Vasilkov
04/06/2021, 10:49 AMDispatchers.Default
makes sense in this case, as it will (probably) be a CPU intensive task which can be bound to CPU cores. But I have little knowledge of Java NIO, sorry.ursus
04/06/2021, 10:51 AMAlex Vasilkov
04/06/2021, 10:55 AMDispatcher.Main
).ursus
04/06/2021, 11:00 AMAlex Vasilkov
04/06/2021, 11:07 AM<http://Dispatchers.IO|Dispatchers.IO>
when working with IO directly, e.g. reading from files, etc.