public class Dispatchers
Groups various implementations of class CoroutineDispatcher.
class CoroutineDispatcher| Modifier and Type | Field and Description |
|---|---|
static CoroutineDispatcher |
Default
The default
class CoroutineDispatcher that is used by all standard builders like
BuildersKt.launch, DeferredKt.async, etc
if no dispatcher nor any other ContinuationInterceptor is specified in their context. |
static Dispatchers |
INSTANCE
Groups various implementations of
class CoroutineDispatcher. |
static CoroutineDispatcher |
Unconfined
A coroutine dispatcher that is not confined to any specific thread.
It executes initial continuation of the coroutine immediately 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.
Note: use with extreme caution, not for general code.
|
public static CoroutineDispatcher Default
The default class CoroutineDispatcher that is used by all standard builders like
BuildersKt.launch, DeferredKt.async, etc
if no dispatcher nor any other ContinuationInterceptor is specified in their context.
It is backed by a shared pool of threads on JVM.
You can set system property "kotlinx.coroutines.scheduler" (either no value or to the value of "on")
to use an experimental coroutine dispatcher that shares threads with DispatchersKt.getIO and thus can switch to
to context without performing an actual thread context switch.
public static CoroutineDispatcher Unconfined
A coroutine dispatcher that is not confined to any specific thread. It executes initial continuation of the coroutine immediately 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. Note: use with extreme caution, not for general code.
Note, that if you need your coroutine to be confined to a particular thread or a thread-pool after resumption,
but still want to execute it in the current call-frame until its first suspension, then you can use
an optional enum CoroutineStart parameter in coroutine builders like
BuildersKt.launch and DeferredKt.async setting it to the
the value of CoroutineStart.UNDISPATCHED.
enum CoroutineStart,
BuildersKt.launch,
DeferredKt.asyncpublic static Dispatchers INSTANCE
Groups various implementations of class CoroutineDispatcher.
class CoroutineDispatcher