threadsafe

Pthreadsafe
Bun

Symbol

FFIFunction.threadsafe

readonly threadsafe?: boolean

Can C/FFI code call this function from a separate thread?

Only supported with JSCallback.

This does not make the function run in a separate thread. It is still up to the application/library to run their code in a separate thread.

By default, JSCallback calls are not thread-safe. Turning this on incurs a small performance penalty for every function call. That small performance penalty needs to be less than the performance gain from running the function in a separate thread.