[−][src]Struct async_io::parking::Parker
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 async_io::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, timeout: 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 async_io::parking::Parker; use std::time::Duration; 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, deadline: 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 async_io::parking::Parker; use std::time::{Duration, Instant}; 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)[src]
Notifies the parker.
Examples
use async_io::parking::Parker; use std::thread; use std::time::Duration; 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();
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,
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.
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>,