Expand description
Thread parking and unparking.
A parker is in either notified or unnotified state. Method park()
blocks
the current thread until the parker becomes notified and then puts it back into unnotified
state. Method unpark()
puts it into notified state.
Examples
use std::thread;
use std::time::Duration;
use parking::Parker;
let p = Parker::new();
let u = p.unparker();
// Notify the parker.
u.unpark();
// Wakes up immediately because the parker is notified.
p.park();
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();
Structs
Functions
Creates a parker and an associated unparker.