DispatcherProvider

interface DispatcherProvider : CoroutineContext.Element

Interface corresponding to the different CoroutineDispatcher's offered by Dispatchers.

Implements the CoroutineContext.Element interface so that it can be embedded into the CoroutineContext map, meaning that a CoroutineContext can be composed with a set of pre-set dispatchers, thereby eliminating the need for singleton references or dependency injecting this interface.

Types

Link copied to clipboard
object Key : CoroutineContext.Key<DispatcherProvider>

Unique Key definition which allows the DispatcherProvider to be stored in the CoroutineContext.

Functions

Link copied to clipboard
open fun copy(default: CoroutineDispatcher = this.default, io: CoroutineDispatcher = this.io, main: CoroutineDispatcher = this.main, mainImmediate: CoroutineDispatcher = this.mainImmediate, unconfined: CoroutineDispatcher = this.unconfined): DispatcherProvider
Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext

Properties

Link copied to clipboard
open val default: CoroutineDispatcher

CoroutineDispatcher generally intended for cpu-bound tasks.

Link copied to clipboard
open val io: CoroutineDispatcher

CoroutineDispatcher generally intended for blocking I/O tasks.

Link copied to clipboard
open override val key: CoroutineContext.Key<*>

This unique Key property is what allows the DispatcherProvider to be stored in the CoroutineContext.

Link copied to clipboard
open val main: CoroutineDispatcher

CoroutineDispatcher which is confined to the "main" thread.

Link copied to clipboard
open val mainImmediate: CoroutineDispatcher

CoroutineDispatcher which is confined to the "main" thread with immediate dispatch.

Link copied to clipboard
open val unconfined: CoroutineDispatcher

CoroutineDispatcher which is unconfined.

Sources

Link copied to clipboard