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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)