[−][src]Module fumio_utils::current
Generic implementation for "current" (thread-local) instances for "executor" handles.
Requires a futures_executor::Enter
reference to set.
Example
pub struct Handle; use futures_executor::Enter; use fumio_utils::current::Current; thread_local! { static CURRENT: Current<Handle> = Current::new(); } pub fn enter<F, R>(handle: Handle, enter: &mut Enter, f: F) -> R where F: FnOnce(&mut Enter) -> R { Current::enter(&CURRENT, enter, handle, f) } pub fn with_current_handle<F, R>(f: F) -> R where F: FnOnce(Option<&Handle>) -> R, { Current::with(&CURRENT, f) }
Structs
Current | Holds a value when entered or nothing when not. |