mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-20 16:29:31 +00:00
Adds a C++ e2e case proving re-entrancy: from inside an `on_echo_fired` handler the consumer issues another request to the library, carrying data taken from the event, and gets a correct response back. The handler runs on the FFI thread with the event-registry lock held, so the test documents and exercises the only safe shape: an *async* request. A synchronous call from the handler would self-deadlock (the FFI thread is busy running the handler), and add/removeEventListener would deadlock on the registry lock. The async request merely queues on the FFI channel and is drained once the handler returns; its future is moved out and resolved on the main thread. A one-shot guard avoids the echo->event->echo storm (echo re-fires the event). Timeouts turn any deadlock regression into a failure rather than a hang. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>