mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-05-17 15:49:27 +00:00
the blocking ffi_call_ which waits on a condvar with the user's timeout (default 30s). Under load this is a thread-explosion factory, and the name "async" is misleading — the Rust side has real async via tokio oneshot, but the C++ side has fake async. If true async isn't reachable in C++ without coroutines, fine, but at least pool the threads or document this is just a convenience wrapper.
nim_timer example
This example is a self-contained Nimble project demonstrating how to import nim-ffi and use the .ffiCtor. / .ffi. abstraction.
Usage
-
Change into the example directory:
cd examples/nim_timer -
Install the local
ffidependency:nimble install -y ../.. -
Build the example library:
nimble build -
Generate bindings:
nimble genbindings_rust nimble genbindings_cpp
Rust example clients
The Rust client lives in examples/nim_timer/rust_client.
-
Run the sync example:
cd examples/nim_timer/rust_client cargo run --bin rust_client -
Run the Tokio example:
cd examples/nim_timer/rust_client cargo run --bin tokio_client
C++ example
The generated C++ example lives in examples/nim_timer/cpp_bindings.
Build and run it with:
cd examples/nim_timer/cpp_bindings
cmake -S . -B build
cmake --build build
./build/example