react-native-vision-cameraInterfaces
AsyncRunner
interface AsyncRunnerAn AsyncRunner can be used to asynchronously
run code in a Frame Processor on a separate, non-blocking
Thread.
Properties
isBusy
isBusy: Synchronizable<boolean>Get whether the AsyncRunner is currently
busy running a task (runAsync(...)),
or not.
Methods
runAsync()
runAsync(task: () => void): booleanRun the given task asynchronously
in a Frame Processor.
This function returns true if the task
was scheduled to run, and false if the asynchronous
runtime is currently busy - in this case you must
drop the Frame.
Parameters
task
The worklet to run asynchronously.
Returns
Whether the task was handled, or not.
Worklet
Example
const frameOutput = useFrameOutput({
onFrame(frame) {
'worklet'
const wasHandled = asyncRunner.runAsync(() => {
'worklet'
doSomeHeavyProcessing(frame)
// Async task finished - dispose the Frame now.
frame.dispose()
})
if (!wasHandled) {
// `AsyncRunner` is busy - drop this Frame!
frame.dispose()
}
}
})