Function critical_section::with

source ·
pub fn with<R>(f: impl FnOnce(CriticalSection<'_>) -> R) -> R
Expand description

Execute closure f in a critical section.

Nesting critical sections is allowed. The inner critical sections are mostly no-ops since they’re already protected by the outer one.

Panics

This function panics if the given closure f panics. In this case the critical section is released before unwinding.