Dispatchers

expect object Dispatchers

Groups various implementations of CoroutineDispatcher.

actual object Dispatchers
actual object Dispatchers

Groups various implementations of CoroutineDispatcher.

actual object Dispatchers

Functions

shutdown
Link copied to clipboard
fun shutdown()

Shuts down built-in dispatchers, such as Default and IO, stopping all the threads associated with them and making them reject all new tasks. Dispatcher used as a fallback for time-related operations (delay, withTimeout) and to handle rejected tasks from other dispatchers is also shut down.

Properties

Default
Link copied to clipboard
expect val Default: CoroutineDispatcher

The default CoroutineDispatcher that is used by all standard builders like launch, async, etc if neither a dispatcher nor any other ContinuationInterceptor is specified in their context.

actual val Default: CoroutineDispatcher
actual val Default: CoroutineDispatcher

The default CoroutineDispatcher that is used by all standard builders like launch, async, etc. if no dispatcher nor any other ContinuationInterceptor is specified in their context.

actual val Default: CoroutineDispatcher
IO
Link copied to clipboard
val IO: CoroutineDispatcher

The CoroutineDispatcher that is designed for offloading blocking IO tasks to a shared pool of threads.

Main
Link copied to clipboard
expect val Main: MainCoroutineDispatcher

A coroutine dispatcher that is confined to the Main thread operating with UI objects. Usually such dispatchers are single-threaded.

actual val Main: MainCoroutineDispatcher
actual val Main: MainCoroutineDispatcher

A coroutine dispatcher that is confined to the Main thread operating with UI objects. This dispatcher can be used either directly or via MainScope factory. Usually such dispatcher is single-threaded.

actual val Main: MainCoroutineDispatcher
Unconfined
Link copied to clipboard
expect val Unconfined: CoroutineDispatcher

A coroutine dispatcher that is not confined to any specific thread. It executes the initial continuation of a coroutine in the current call-frame and lets the coroutine resume in whatever thread that is used by the corresponding suspending function, without mandating any specific threading policy. Nested coroutines launched in this dispatcher form an event-loop to avoid stack overflows.

actual val Unconfined: CoroutineDispatcher
actual val Unconfined: CoroutineDispatcher

A coroutine dispatcher that is not confined to any specific thread. It executes initial continuation of the coroutine in the current call-frame and lets the coroutine resume in whatever thread that is used by the corresponding suspending function, without mandating any specific threading policy. Nested coroutines launched in this dispatcher form an event-loop to avoid stack overflows.

actual val Unconfined: CoroutineDispatcher

Sources

common source
Link copied to clipboard
js source
Link copied to clipboard
jvm source
Link copied to clipboard
native source
Link copied to clipboard