local_waker_fn

Function local_waker_fn 

Source
pub fn local_waker_fn<F>(f: F) -> LocalWaker
where F: Fn() + Send + Sync + 'static,
🔬This is a nightly-only experimental API. (waker_fn)
Expand description

Converts a closure into a LocalWaker.

The closure gets called every time the local waker is woken.

§Examples

#![feature(local_waker)]
#![feature(waker_fn)]
use std::task::local_waker_fn;

let waker = local_waker_fn(|| println!("woken"));

waker.wake_by_ref(); // Prints "woken".
waker.wake();        // Prints "woken".