File tree 1 file changed +4
-4
lines changed
kotlinx-coroutines-core/nativeOther/src
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 5
5
package kotlinx.coroutines
6
6
7
7
import kotlin.coroutines.*
8
+ import kotlin.native.*
8
9
9
10
internal actual fun createMainDispatcher (default : CoroutineDispatcher ): MainCoroutineDispatcher =
10
11
MissingMainDispatcher
11
12
12
13
internal actual fun createDefaultDispatcher (): CoroutineDispatcher = DefaultDispatcher
13
14
14
15
private object DefaultDispatcher : CoroutineDispatcher() {
15
-
16
- // Delegated, so users won't be able to downcast and call 'close'
17
- // The precise number of threads cannot be obtained until KT-48179 is implemented, 4 is just "good enough" number.
18
- private val ctx = newFixedThreadPoolContext(4 , " Dispatchers.Default" )
16
+ // Be consistent with JVM -- at least 2 threads to provide some liveness guarantees in case of improper uses
17
+ @OptIn(ExperimentalStdlibApi ::class )
18
+ private val ctx = newFixedThreadPoolContext(Platform .getAvailableProcessors().coerceAtLeast(2 ), " Dispatchers.Default" )
19
19
20
20
override fun dispatch (context : CoroutineContext , block : Runnable ) {
21
21
ctx.dispatch(context, block)
You can’t perform that action at this time.
0 commit comments