mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-21 16:59:30 +00:00
First increment of typed host callbacks (roadmap #1): the data-structure layer, independent of the FFI thread and the macro so it can be unit-tested in isolation. - FFIHostRegistry: wire-name -> (host fn ptr, userData). A missing entry is a normal outcome (the imported proc errors), never a crash — never-crash policy. nil fn unregisters. - FFIPendingTable: monotonic token -> the chronos Future an awaiting {.ffiHost.} proc is blocked on. completePending drops unknown/double completions; failAllPending errors every outstanding future on teardown so no awaiting handler is abandoned. Both lock-guarded so a host thread and the FFI thread can touch them concurrently; futures are only ever completed on the FFI thread. 6 unit tests pass under orc and refc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
15 lines
426 B
Nim
15 lines
426 B
Nim
import std/[atomics, tables]
|
|
import chronos, chronicles
|
|
import
|
|
ffi/internal/[ffi_library, ffi_macro],
|
|
ffi/[
|
|
alloc, ffi_types, ffi_events, ffi_host, ffi_context, ffi_context_pool,
|
|
ffi_thread_request, cbor_serial,
|
|
]
|
|
|
|
export atomics, tables
|
|
export chronos, chronicles
|
|
export
|
|
atomics, alloc, ffi_library, ffi_macro, ffi_types, ffi_events, ffi_host,
|
|
ffi_context, ffi_context_pool, ffi_thread_request, cbor_serial
|