public class MainCoroutineDispatcher
extends CoroutineDispatcher
Base class for special class 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.getMain
.
Platform may or may not provide instance of MainDispatcher
, see documentation to Dispatchers.getMain
Constructor and Description |
---|
MainCoroutineDispatcher()
Base class for special
class 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.getMain . |
Modifier and Type | Method and Description |
---|---|
MainCoroutineDispatcher |
getImmediate()
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). See
CoroutineDispatcher.isDispatchNeeded documentation on
why this should not be done by default.
Method may throw UnsupportedOperationException if immediate dispatching is not supported by current dispatcher,
please refer to specific dispatcher documentation. |
dispatch, interceptContinuation, isDispatchNeeded
public MainCoroutineDispatcher()
Base class for special class 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.getMain
.
Platform may or may not provide instance of MainDispatcher
, see documentation to Dispatchers.getMain
public MainCoroutineDispatcher getImmediate()
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). See CoroutineDispatcher.isDispatchNeeded
documentation on
why this should not be done by default.
Method may throw UnsupportedOperationException if immediate dispatching is not supported by current dispatcher,
please refer to specific dispatcher documentation.
Note: This is an experimental api. Semantics of this dispatcher may change in the future.