detached

Function detached 

Source
pub fn detached<T>(operation: impl FnOnce() -> T) -> T
Expand description

Run operation with none of this thread’s lexical resource state: no account, source stop, terminal or owned stop observer.

A rayon wait (join, par_iter) may run an unrelated queued job on the waiting thread before it returns, such as another element’s whole product. That job is not part of the caller’s work: it must not bill the caller’s account, observe the caller’s source stop or terminal, or record its own stop into them. Wrap every rayon wait inside product work in this; the caller’s state is restored on return and on unwind. operation itself must not need the caller’s resource state.

This hides RESOURCE state only (including the owned stop observer). Other per-thread diagnostic capture, such as geometry telemetry transactions and the CSG census sink, is not scoped by it.