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.
Sourcepub fn as_raw_fd(&self) -> i32
pub fn as_raw_fd(&self) -> i32
File descriptor for epoll/kqueue/poll(2) registration.
Becomes readable when wake() has been called.
Sourcepub fn try_clone_read_fd(&self) -> Result<OwnedFd, Error>
pub fn try_clone_read_fd(&self) -> Result<OwnedFd, Error>
Clone the pollable read end for an independently owned registration.
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more