pub fn with_default_runtime<R>(
f: impl FnOnce(&mut RuntimeContext) -> Result<R>,
) -> Result<R>Expand description
Runs f with the default runtime context.
Returns Error::RuntimeNotConfigured when runtime is not configured.
ยงExamples
use tenferro_internal_runtime::{set_default_runtime, with_default_runtime, RuntimeContext};
use tenferro_prims::CpuContext;
let _guard = set_default_runtime(RuntimeContext::Cpu(CpuContext::new(1)));
let name = with_default_runtime(|ctx| Ok(ctx.name())).unwrap();
assert_eq!(name, "cpu");