Skip to content

Commit 674f84b

Browse files
committed
Update Dispatchers docs to account for native-mt changes
Fixes #1828
1 parent 80e3100 commit 674f84b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

kotlinx-coroutines-core/common/src/Dispatchers.common.kt

+12-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ public expect object Dispatchers {
1515
* [launch][CoroutineScope.launch], [async][CoroutineScope.async], etc
1616
* if neither a dispatcher nor any other [ContinuationInterceptor] is specified in their context.
1717
*
18-
* It is backed by a shared pool of threads on JVM. By default, the maximum number of threads used
19-
* by this dispatcher is equal to the number of CPU cores, but is at least two.
18+
* Its implementation depends on the platform:
19+
* - On Kotlin/JVM it is backed by a shared pool of threads. By default, the maximum number of threads used
20+
* by this dispatcher is equal to the number of CPU cores, but is at least two.
21+
* - On Kotlin/JS it backed by the JS event loop.
22+
* - On Kotlin/Native it is backed by a single background thread that is created on the first use.
2023
*/
2124
public val Default: CoroutineDispatcher
2225

@@ -26,15 +29,17 @@ public expect object Dispatchers {
2629
*
2730
* Access to this property may throw an [IllegalStateException] if no main dispatchers are present in the classpath.
2831
*
29-
* Depending on platform and classpath it can be mapped to different dispatchers:
30-
* - On JS and Native it is equivalent to the [Default] dispatcher.
31-
* - On JVM it either the Android main thread dispatcher, JavaFx or Swing EDT dispatcher. It is chosen by the
32+
* Depending on the platform and classpath it can be mapped to different dispatchers:
33+
* - On Kotlin/JVM it either the Android main thread dispatcher, JavaFx or Swing EDT dispatcher. It is chosen by the
3234
* [`ServiceLoader`](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html).
35+
* - On Kotlin/JS it is equivalent to the [Default] dispatcher.
36+
* - On Kotlin/Native Apple platforms it maps to the Darwin main thread.
37+
* - On other Kotlin/Native platforms it is equivalent to the [Default] dispatcher.
3338
*
34-
* In order to work with the `Main` dispatcher, the following artifact should be added to the project runtime dependencies:
39+
* In order to work with the `Main` dispatcher on Kotlin/JVM, the following artifact should be added to the project runtime dependencies:
3540
* - `kotlinx-coroutines-android` — for Android Main thread dispatcher
3641
* - `kotlinx-coroutines-javafx` — for JavaFx Application thread dispatcher
37-
* - `kotlinx-coroutines-swing` — for Swing EDT dispatcher
42+
* - `kotlinx-coroutines-swing` — for Swing EDT dispatcher.
3843
*
3944
* Implementation note: [MainCoroutineDispatcher.immediate] is not supported on the Native and JS platforms.
4045
*/

0 commit comments

Comments
 (0)