Function local_waker_fn

fn local_waker_fn<F: Fn() + Send + Sync + 'static>(f: F) -> core::task::LocalWaker

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".