MainCoroutineDispatcher

Base class for special CoroutineDispatcher which is confined to application "Main" or "UI" thread and used for any UI-based activities. Instance of MainDispatcher can be obtained by Dispatchers.Main.

Platform may or may not provide instance of MainDispatcher, see documentation to Dispatchers.Main

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Returns dispatcher that executes coroutines immediately when it is already in the right context (e.g. current looper is the same as this handler's looper) without an additional re-dispatch.

Functions

Link copied to clipboard
open override fun limitedParallelism(parallelism: Int, name: String?): CoroutineDispatcher

Creates a view of the current dispatcher that limits the parallelism to the given value. The resulting view uses the original dispatcher for execution but with the guarantee that no more than parallelism coroutines are executed at the same time.

Link copied to clipboard
open override fun toString(): String

Returns a name of this main dispatcher for debugging purposes. This implementation returns Dispatchers.Main or Dispatchers.Main.immediate if it is the same as the corresponding reference in Dispatchers or a short class-name representation with address otherwise.