Christian Würthenr
10/31/2022, 8:29 AM<http://Dispatchers.IO|Dispatchers.IO>
available, but that's not the case in KMM. What's the best way to replace it? I already have a expected
actual
with a Dispatcher.SharedIO
which just points to <http://Dispatchers.IO|Dispatchers.IO>
on Android, but what's the best solution on iOS?shahroz
10/31/2022, 9:47 AMSeb Jachec
10/31/2022, 9:51 AMDispatchers.Main
implementation anyway? https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt#L32-L43 (and https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/native/src/Dispatchers.kt)Christian Würthenr
10/31/2022, 9:54 AMDispatchers.Main
seems to use the main dispatch queue, that would block the main thread I assume? (not an iOS dev)Christian Würthenr
10/31/2022, 9:55 AMDarwinGlobalQueueDispatcher
which is mapped to Dispatchers.Default
does pretty much the sameSeb Jachec
10/31/2022, 9:57 AMDispatchers.Main
would block the main thread afaikChristian Würthenr
10/31/2022, 9:57 AM<http://Dispatchers.IO|Dispatchers.IO>
with Dispatchers.Default
in KMM, but that lead to the app being dead locked on devices with low CPU core counts as on Android Dispatchers.Default
is limited to one thread per core. Looking at the iOS implementation now, that seems not to be the case on iOSChristian Würthenr
10/31/2022, 9:58 AMexpect Dispatchers.SharedIO: CoroutineDispatcher
iOS is then
actual Dispatchers.SharedIO = Dispatchers.Default
and Android
actual Dispatchers.SharedIO = <http://Dispatchers.IO|Dispatchers.IO>
shahroz
10/31/2022, 9:59 AMDispatchers.Default
limited thread count seemed to be a problem.
But maybe, newFixedThreadPoolContext
can fix thisChristian Würthenr
10/31/2022, 10:02 AMshahroz
10/31/2022, 10:06 AMChristian Würthenr
10/31/2022, 10:08 AMChristian Würthenr
10/31/2022, 10:08 AM