Skip to main content
JSCallback wraps a TypeScript function so it can be passed to C code that expects a function pointer.

Example

Constructor

Properties

ptr

Returns a function pointer that can be passed to native C code.
  • Non-threadsafe: returns a slot handle (small integer).
  • Threadsafe: returns a real executable trampoline address.

getHandle()

Returns the internal slot handle, used for ffi.invokeCallback() and ffi.callCallbackThreadSafe().

threadsafe

Whether the callback was created with thread-safe mode.

Methods

call()

Invokes the TypeScript callback.

close()

Releases the callback resources.

Thread-Safe Callbacks

When threadsafe: true, cb.ptr returns a real C function pointer (trampoline) that can be passed directly to native C functions:

Closure Capture