NativeThreadFactory

interface NativeThreadFactory extends HybridObject

A factory for creating NativeThreads.

Typically you would never need this as Camera Outputs create NativeThreads.

You can create NativeThreads for advanced asynchronous processing on a Worklet Queue, in which case VisionCamera prepares the necessary setup such as installing a Dispatcher to your Worklet Runtime.

Methods

createNativeThread()

createNativeThread(name: string): NativeThread

Create a new NativeThread.

A NativeThread can be used for Camera operations such as Frame Processing. It uses platform native dispatching mechanisms like DispatchQueue or CoroutineContext.

You can use the WorkletQueueFactory to wrap the NativeThread in a WorkletQueue, which allows you to run JS code on the thread.

Example

Creating a Worklet Runtime using this NativeThread:

const thread = NativeThreadFactory.createNativeThread('async-processor')
const runtime = createWorkletRuntimeForThread(thread)