Struct crossbeam_utils::sync::Unparker
source · pub struct Unparker { /* private fields */ }Expand description
Unparks a thread parked by the associated Parker.
Implementations§
source§impl Unparker
impl Unparker
sourcepub fn unpark(&self)
pub fn unpark(&self)
Atomically makes the token available if it is not already.
This method will wake up the thread blocked on park or park_timeout, if there is
any.
Examples
use std::thread;
use std::time::Duration;
use crossbeam_utils::sync::Parker;
let mut p = Parker::new();
let u = p.unparker().clone();
thread::spawn(move || {
thread::sleep(Duration::from_millis(500));
u.unpark();
});
// Wakes up when `u.unpark()` provides the token, but may also wake up
// spuriously before that without consuming the token.
p.park();