Expand description
Worker thread infrastructure for safe Rust-R FFI.
§Public API
with_r_thread— Execute a closure on R’s main threadis_r_main_thread— Check if the current thread is R’s main thread
§Feature gate: worker-thread
Without the worker-thread cargo feature, all calls execute inline on
R’s main thread:
with_r_thread(f)runsf()directly (panics if not on main thread)run_on_worker(f)runsf()directly, returnsOk(f())
With the feature enabled, a dedicated worker thread is spawned at init time.
with_r_thread routes calls from the worker back to main, and run_on_worker
dispatches closures to the worker with bidirectional communication.
§Initialization
[miniextendr_runtime_init] must be called from R’s main thread before any
R FFI APIs. Typically done in R_init_<pkgname>().
Statics§
Functions§
- assert_
runtime_ 🔒initialized - Panic if the runtime hasn’t been initialized.
- has_
worker_ 🔒context - Check whether the current thread has a worker routing context.
- is_
r_ main_ thread - Check if the current thread is R’s main thread.
- with_
r_ thread - Execute a closure on R’s main thread, returning the result.