Scoop API

scoop:scoop.core:0.1.0

foreignCallback

function foreignCallback

source · line 55
public
@Unsafe
@Intrinsic("foreign_callback_register")
public fun <F> foreignCallback(callback: Any, contextIndex: Long, mode: ForeignCallbackMode): ForeignCallback<F>

Registers a managed non-suspending function behind a native trampoline. F must be an explicit concrete C-safe signature; contextIndex and mode are compile-time constants, and the context parameter is Ptr<Unit>. Reusable owners release after native unregister. A successful one-shot launch transfers its worker ownership to the callback; retain a separate observer before that transfer when needed.