pub async fn spawn_compute<F, R>(f: F) -> RExpand description
Spawn compute work using the current runtime.
This is a convenience function for loom_rs::current_runtime().unwrap().spawn_compute(f).
It allows spawning compute work from anywhere within a loom runtime without
explicitly passing the runtime reference.
§Panics
Panics if called outside a loom runtime context (i.e., not within block_on,
a tokio worker thread, or a rayon worker thread managed by the runtime).
§Performance
Same as LoomRuntime::spawn_compute():
- 0 bytes allocation after warmup (pool hit)
- ~100-500ns overhead
§Example
ⓘ
use loom_rs::LoomBuilder;
let runtime = LoomBuilder::new().build()?;
runtime.block_on(async {
// No need to pass &runtime around
let result = loom_rs::spawn_compute(|| {
expensive_work()
}).await;
});