@@ -15,8 +15,11 @@ public expect object Dispatchers {
15
15
* [launch][CoroutineScope.launch], [async][CoroutineScope.async], etc
16
16
* if neither a dispatcher nor any other [ContinuationInterceptor] is specified in their context.
17
17
*
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.
20
23
*/
21
24
public val Default : CoroutineDispatcher
22
25
@@ -26,15 +29,17 @@ public expect object Dispatchers {
26
29
*
27
30
* Access to this property may throw an [IllegalStateException] if no main dispatchers are present in the classpath.
28
31
*
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
32
34
* [`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.
33
38
*
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:
35
40
* - `kotlinx-coroutines-android` — for Android Main thread dispatcher
36
41
* - `kotlinx-coroutines-javafx` — for JavaFx Application thread dispatcher
37
- * - `kotlinx-coroutines-swing` — for Swing EDT dispatcher
42
+ * - `kotlinx-coroutines-swing` — for Swing EDT dispatcher.
38
43
*
39
44
* Implementation note: [MainCoroutineDispatcher.immediate] is not supported on the Native and JS platforms.
40
45
*/
0 commit comments