Skip to main content

current_runtime

Function current_runtime 

Source
pub fn current_runtime() -> Option<Arc<LoomRuntimeInner>>
Expand description

Get the current loom runtime from thread-local storage.

Returns Some when called from a thread managed by a LoomRuntime (tokio workers, rayon workers, or within block_on).

Returns None when called from outside a loom runtime context.

§Example

runtime.block_on(async {
    // Works anywhere in the runtime's threads
    let rt = loom_rs::current_runtime().unwrap();
    rt.spawn_compute(|| work()).await;
});