From 08e3db06fe75d89c5677530042dc0078024f22b7 Mon Sep 17 00:00:00 2001 From: Roman Elizarov Date: Fri, 13 Mar 2020 16:43:42 +0300 Subject: [PATCH] Update Dispatchers docs to account for native-mt changes Fixes #1828 --- .../common/src/Dispatchers.common.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/kotlinx-coroutines-core/common/src/Dispatchers.common.kt b/kotlinx-coroutines-core/common/src/Dispatchers.common.kt index dba57abc88..4d9db565d9 100644 --- a/kotlinx-coroutines-core/common/src/Dispatchers.common.kt +++ b/kotlinx-coroutines-core/common/src/Dispatchers.common.kt @@ -15,8 +15,11 @@ public expect object Dispatchers { * [launch][CoroutineScope.launch], [async][CoroutineScope.async], etc * if neither a dispatcher nor any other [ContinuationInterceptor] is specified in their context. * - * It is backed by a shared pool of threads on JVM. By default, the maximum number of threads used - * by this dispatcher is equal to the number of CPU cores, but is at least two. + * Its implementation depends on the platform: + * - On Kotlin/JVM it is backed by a shared pool of threads. By default, the maximum number of threads used + * by this dispatcher is equal to the number of CPU cores, but is at least two. + * - On Kotlin/JS it backed by the JS event loop. + * - On Kotlin/Native it is backed by a single background thread that is created on the first use. */ public val Default: CoroutineDispatcher @@ -26,15 +29,17 @@ public expect object Dispatchers { * * Access to this property may throw an [IllegalStateException] if no main dispatchers are present in the classpath. * - * Depending on platform and classpath it can be mapped to different dispatchers: - * - On JS and Native it is equivalent to the [Default] dispatcher. - * - On JVM it either the Android main thread dispatcher, JavaFx or Swing EDT dispatcher. It is chosen by the + * Depending on the platform and classpath it can be mapped to different dispatchers: + * - On Kotlin/JVM it either the Android main thread dispatcher, JavaFx or Swing EDT dispatcher. It is chosen by the * [`ServiceLoader`](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html). + * - On Kotlin/JS it is equivalent to the [Default] dispatcher. + * - On Kotlin/Native Apple platforms it maps to the Darwin main thread. + * - On other Kotlin/Native platforms it is equivalent to the [Default] dispatcher. * - * In order to work with the `Main` dispatcher, the following artifact should be added to the project runtime dependencies: + * In order to work with the `Main` dispatcher on Kotlin/JVM, the following artifact should be added to the project runtime dependencies: * - `kotlinx-coroutines-android` — for Android Main thread dispatcher * - `kotlinx-coroutines-javafx` — for JavaFx Application thread dispatcher - * - `kotlinx-coroutines-swing` — for Swing EDT dispatcher + * - `kotlinx-coroutines-swing` — for Swing EDT dispatcher. * * Implementation note: [MainCoroutineDispatcher.immediate] is not supported on the Native and JS platforms. */