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();
Sourcepub fn will_unpark(&self, parker: &Parker) -> bool
pub fn will_unpark(&self, parker: &Parker) -> bool
Indicates whether this unparker will unpark the associated parker.
This can be used to avoid unnecessary work before calling unpark()
.
§Examples
use parking::Parker;
let p = Parker::new();
let u = p.unparker();
assert!(u.will_unpark(&p));
Sourcepub fn same_parker(&self, other: &Unparker) -> bool
pub fn same_parker(&self, other: &Unparker) -> bool
Indicates whether two unparkers will unpark the same parker.
§Examples
use parking::Parker;
let p = Parker::new();
let u1 = p.unparker();
let u2 = p.unparker();
assert!(u1.same_parker(&u2));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Unparker
impl RefUnwindSafe for Unparker
impl Send for Unparker
impl Sync for Unparker
impl Unpin for Unparker
impl UnwindSafe for Unparker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more