<init>
CoroutineDispatcher()
Base class that shall be extended by all coroutine dispatcher implementations.
The following standard implementations are provided by kotlinx.coroutines
:
- Unconfined – starts coroutine execution in the current call-frame until the first suspension. On first suspension the coroutine builder function returns. The coroutine will resume in whatever thread that is used by the corresponding suspending function, without confining it to any specific thread or pool. This in an appropriate choice for IO-intensive coroutines that do not consume CPU resources.
- DefaultDispatcher – is used by all standard builder if no dispatcher nor any other ContinuationInterceptor is specified in their context. It is currently equal to CommonPool (subject to change).
- CommonPool – immediately returns from the coroutine builder and schedules coroutine execution to a common pool of shared background threads. This is an appropriate choice for compute-intensive coroutines that consume a lot of CPU resources.
- Private thread pools can be created with newSingleThreadContext and newFixedThreadPoolContext.
- An arbitrary Executor can be converted to dispatcher with asCoroutineDispatcher extension function.
This class ensures that debugging facilities in newCoroutineContext function work properly.