pub struct Waker(/* private fields */);Expand description
Ends a Backend::read under way early, from any thread: a value made
on another thread is then picked up at once, rather than when the read’s
timeout runs out. Clones wake the same reads. A wake that comes while
no read is under way ends the next one at once, so none is lost; a
read woken returns None, as if its timeout had passed.
Session waits on it with the terminal (a self-pipe beside the
terminal in one poll, on Unix; elsewhere it looks between short
waits). Any other backend, or a loop of one’s own, can wait on it with
wait.
use rich_interact::Waker;
use std::time::Duration;
let waker = Waker::new();
let other = waker.clone();
std::thread::spawn(move || other.wake());
assert!(waker.wait(Duration::from_secs(5)));
// Taken: the next wait waits.
assert!(!waker.wait(Duration::from_millis(1)));Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Waker
impl RefUnwindSafe for Waker
impl Send for Waker
impl Sync for Waker
impl Unpin for Waker
impl UnsafeUnpin for Waker
impl UnwindSafe for Waker
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