Skip to content

Commit

Permalink
Update Dispatchers docs to account for native-mt changes
Browse files Browse the repository at this point in the history
Fixes #1828
  • Loading branch information
elizarov committed Mar 31, 2020
1 parent f75c534 commit 57715e9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kotlinx-coroutines-core/common/src/Dispatchers.common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
*/
Expand Down

0 comments on commit 57715e9

Please sign in to comment.