Source set: Android
public class AndroidUiDispatcher private constructor(
public val choreographer: Choreographer,
private val handler: android.os.Handler,
) : CoroutineDispatcher()
Properties
frameClock
Source set: Android
public val frameClock: MonotonicFrameClock = AndroidUiFrameClock(choreographer, this)
A MonotonicFrameClock associated with this AndroidUiDispatcher's choreographer that may be used to await Choreographer frame dispatch.
Functions
dispatch
Source set: Android
override fun dispatch(context: CoroutineContext, block: Runnable)
Members
Companion
Source set: Android
public companion object
Properties
Main
Source set: Android
public val Main: CoroutineContext by
lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
val dispatcher =
AndroidUiDispatcher(
if (isMainThread()) Choreographer.getInstance()
else runBlocking(Dispatchers.Main) { Choreographer.getInstance() },
HandlerCompat.createAsync(Looper.getMainLooper()),
)
dispatcher + dispatcher.frameClock
}
The CoroutineContext containing the AndroidUiDispatcher and its frameClock for the process's main thread.
CurrentThread
Source set: Android
public val CurrentThread: CoroutineContext
The canonical CoroutineContext containing the AndroidUiDispatcher and its frameClock for the calling thread. Returns Main if accessed from the process's main thread.
Throws IllegalStateException if the calling thread does not have both a Choreographer and an active Looper.