Class

BroadcastFrameClock

A simple frame clock.

Source set: Common

Added in 1.11.0-rc01

public class BroadcastFrameClock(private val onNewAwaiters: (() -> Unit)? = null) :
    MonotonicFrameClock

A simple frame clock.

This implementation is intended for low-contention environments involving low total numbers of threads in a pool on the order of ~number of CPU cores available for UI recomposition work, while avoiding additional allocation where possible.

onNewAwaiters will be invoked whenever the number of awaiters has changed from 0 to 1. If onNewAwaiters fails by throwing an exception it will permanently fail this BroadcastFrameClock; all current and future awaiters will resume with the thrown exception.

Properties

hasAwaiters

Source set: Common

Added in 1.11.0-rc01

public val hasAwaiters: Boolean

true if there are any callers of withFrameNanos awaiting to run for a pending frame.

Functions

sendFrame

sendFrame

Added in 1.11.0-rc01

public fun sendFrame(timeNanos: Long)

Send a frame for time timeNanos to all current callers of withFrameNanos. The onFrame callback for each caller is invoked synchronously during the call to sendFrame.

cancel


cancel

Added in 1.11.0-rc01

public fun cancel(
        cancellationException: CancellationException = CancellationException("clock cancelled")
    )

Permanently cancel this BroadcastFrameClock and cancel all current and future awaiters with cancellationException.

Last updated: