Skip to main content

with_kernel_context

Function with_kernel_context 

Source
pub fn with_kernel_context<F, R>(ctx: KernelContext, f: F) -> R
where F: FnOnce() -> R,
Expand description

Execute a closure with a kernel context set, then clear the context.

This is the preferred way to scope kernel context to a region of code. The context is guaranteed to be cleared even if the closure panics (via drop semantics of the thread-local borrow).