Skip to main content

current_section

Function current_section 

Source
pub fn current_section() -> Option<&'static PersistentSection>
Expand description

Returns the current thread-local section, if one is installed via PersistentSection::install_tls. Used by yscv-kernels to route par_chunks_mut_dispatch through PersistentSection::parallel_for instead of rayon’s fork-join when a session is active.

§Safety (caller discipline)

The 'static lifetime is a white lie — the returned reference is only valid while the corresponding SectionGuard is alive on this thread. Callers must not stash the reference across points where the guard could drop. The standard usage pattern (look up, call parallel_for, discard) is safe because the guard is rooted in OnnxRunner::run and outlives every synchronous dispatch.