pub struct Unparker { /* private fields */ }
Expand description
Notifies a parker.
Implementations§
source§impl Unparker
impl Unparker
sourcepub fn unpark(&self) -> bool
pub fn unpark(&self) -> bool
Notifies the associated parker.
Returns true
if this call is the first to notify the parker, or false
if the parker
was already notified.
Examples
use std::thread;
use std::time::Duration;
use parking::Parker;
let p = Parker::new();
let u = p.unparker();
thread::spawn(move || {
thread::sleep(Duration::from_millis(500));
u.unpark();
});
// Wakes up when `u.unpark()` notifies and then goes back into unnotified state.
p.park();