pub struct WakePipe { /* private fields */ }Expand description
Cross-platform wake notification.
On Unix, the write end signals and the read end is pollable via
epoll/kqueue/poll. On Windows, wakeups are coalesced behind a
manual-reset event for code that needs a blocking wait.
Implementations§
Source§impl WakePipe
impl WakePipe
Sourcepub fn new() -> WakePipe
pub fn new() -> WakePipe
Create a new wake pipe.
Both ends are set to non-blocking and close-on-exec.
Sourcepub fn wake(&self)
pub fn wake(&self)
Signal the reader. Safe to call from any thread, multiple times.
Writes a single byte. If the pipe buffer is full the write is silently dropped — the reader will still wake because there are unread bytes.
Sourcepub fn drain(&self)
pub fn drain(&self)
Drain all pending wake signals. Call after processing to reset the pipe for the next edge-triggered notification.
Sourcepub fn wait_timeout(&self, timeout: Duration) -> bool
pub fn wait_timeout(&self, timeout: Duration) -> bool
Block until the wake primitive is signaled or the timeout expires.
Returns true if the primitive was signaled and false on timeout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WakePipe
impl RefUnwindSafe for WakePipe
impl Send for WakePipe
impl Sync for WakePipe
impl Unpin for WakePipe
impl UnsafeUnpin for WakePipe
impl UnwindSafe for WakePipe
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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