NativeThread

interface NativeThread

A native thread: an Executor on Android, a DispatchQueue on iOS.

Streaming outputs like the CameraFrameOutput expose the NativeThread their callbacks run on, so further work can run on the same thread without any thread hop. A NativeThread may use a thread pool, but it never runs code in parallel: execution is always serial.

See also

Properties

Link copied to clipboard
abstract val id: String

This thread's ID.

Functions

Link copied to clipboard
fun NativeThread.asCoroutineDispatcher(): CoroutineDispatcher

A CoroutineDispatcher running coroutines on this NativeThread, e.g. to process frames asynchronously on the output's thread with withContext(frameOutput.thread.asCoroutineDispatcher()).

Link copied to clipboard
abstract fun runOnThread(task: () -> Unit)

Runs the given task on this thread.