Skip to main content

miniextendr_runtime_shutdown

Function miniextendr_runtime_shutdown 

Source
#[doc(hidden)]
#[unsafe(no_mangle)]
pub extern "C-unwind" fn miniextendr_runtime_shutdown()
Expand description

Shut down the miniextendr worker thread synchronously.

Called from R_unload_<pkg> (generated by miniextendr_init!). Sends a Shutdown message to the worker, drops the sender, and blocks on JoinHandle::join() until the worker thread has fully exited. Must block: library.dynam.unload unmaps the DLL’s code pages as soon as this returns, and a still-live worker would resume execution in freed memory (see #277).

Idempotent. After the first call, the join handle is taken and subsequent calls are no-ops. Safe to call from any thread, though R only ever calls it from the main thread.

Additionally uninstalls the process panic hook that this DLL registered (also in DLL code — see backtrace::miniextendr_panic_hook_uninstall).

Without the worker-thread feature this is (mostly) a no-op: only the panic hook uninstall runs.