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() -> Self
pub fn new() -> Self
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.
Sourcepub fn as_raw_fd(&self) -> RawFd
pub fn as_raw_fd(&self) -> RawFd
File descriptor for epoll/kqueue/poll(2) registration.
Becomes readable when wake() has been called.
Sourcepub fn try_clone_read_fd(&self) -> Result<OwnedFd>
pub fn try_clone_read_fd(&self) -> Result<OwnedFd>
Clone the pollable read end for an independently owned registration.