DispatchersProvider

Component that provides different CoroutineDispatchers for various coroutine contexts.

This component defines methods to retrieve dispatchers for the main, default, IO, and unconfined contexts in coroutine-based applications to manage concurrency and threading.

Functions

Link copied to clipboard
abstract fun default(): CoroutineDispatcher

Returns the default CoroutineDispatcher. This dispatcher is optimized for CPU-intensive tasks.

Link copied to clipboard
abstract fun io(): CoroutineDispatcher

Returns the IO CoroutineDispatcher, which is optimized for IO-bound tasks, such as reading from or writing to the network or disk.

Link copied to clipboard
abstract fun main(): CoroutineDispatcher

Returns the main CoroutineDispatcher, which should be typically used for UI-related tasks.

Link copied to clipboard
abstract fun unconfined(): CoroutineDispatcher

Returns the unconfined CoroutineDispatcher. This dispatcher starts coroutines in the caller thread but only until the first suspension point.