Struct parking::Parker [−][src]
Waits for a notification.
Implementations
impl Parker
[src]
pub fn new() -> Parker
[src]
pub fn park(&self)
[src]
Blocks until notified and then goes back into unnotified state.
Examples
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();
pub fn park_timeout(&self, duration: Duration) -> bool
[src]
Blocks until notified and then goes back into unnotified state, or times out after
duration
.
Returns true
if notified before the timeout.
Examples
use std::time::Duration; use parking::Parker; let p = Parker::new(); // Wait for a notification, or time out after 500 ms. p.park_timeout(Duration::from_millis(500));
pub fn park_deadline(&self, instant: Instant) -> bool
[src]
Blocks until notified and then goes back into unnotified state, or times out at instant
.
Returns true
if notified before the deadline.
Examples
use std::time::{Duration, Instant}; use parking::Parker; let p = Parker::new(); // Wait for a notification, or time out after 500 ms. p.park_deadline(Instant::now() + Duration::from_millis(500));
pub fn unpark(&self) -> bool
[src]
Notifies the 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(); assert_eq!(p.unpark(), true); assert_eq!(p.unpark(), false); // Wakes up immediately. p.park();
pub fn unparker(&self) -> Unparker
[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Parker
impl Send for Parker
impl !Sync for Parker
impl Unpin for Parker
impl !UnwindSafe for Parker
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,