Skip to main content

propagate

Function propagate 

Source
pub fn propagate<F>(fut: F) -> impl Future<Output = F::Output> + Send
where F: Future + Send + 'static, F::Output: Send,
Expand description

Wrap fut so it runs under the CURRENT execution context — captured now (at the call site, which is still inside the parent’s scope) and re-established as the task-local inside a freshly-spawned task. A no-op pass-through when there is no current context (single-run / CLI / tests — axiom A1).

tokio::spawn / JoinSet::spawn start a NEW task that does not inherit the parent’s task-locals, so the per-execution context (observer, scene tree, stop flag, exec_id) would be lost in the spawned per-cycle fibers. Wrapping each spawned future with propagate carries the context across the spawn boundary, so a fiber deep inside a concurrent execution still resolves to its execution’s state.