pub struct Waiter { /* private fields */ }Expand description
A type that can put a thread to sleep waiting for a condition.
Implementations§
Source§impl Waiter
impl Waiter
Sourcepub fn new_ignoring_signals() -> Self
pub fn new_ignoring_signals() -> Self
Create a new waiter that doesn’t wake up when a signal is received.
Sourcepub fn freeze<L>(&self, locked: &mut Locked<L>, current_task: &CurrentTask)where
L: LockEqualOrBefore<FileOpsCore>,
pub fn freeze<L>(&self, locked: &mut Locked<L>, current_task: &CurrentTask)where
L: LockEqualOrBefore<FileOpsCore>,
Freeze the task until the waiter is woken up.
No signal, e.g. EINTR (interrupt), should be received.
Sourcepub fn wait<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn wait<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Wait until the waiter is woken up.
If the wait is interrupted (see Waiter::interrupt), this function returns EINTR.
Sourcepub fn wait_until<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
deadline: MonotonicInstant,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn wait_until<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
deadline: MonotonicInstant,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Wait until the given deadline has passed or the waiter is woken up.
If the wait deadline is nonzero and is interrupted (see Waiter::interrupt), this
function returns EINTR. Callers must take special care not to lose any accumulated data or
local state when EINTR is received as this is a normal and recoverable situation.
Using a 0 deadline (no waiting, useful for draining pending events) will not wait and is guaranteed not to issue EINTR.
It the timeout elapses with no events, this function returns ETIMEDOUT.
Processes at most one event. If the caller is interested in draining the events, it should repeatedly call this function with a 0 deadline until it reports ETIMEDOUT. (This case is why a 0 deadline must not return EINTR, as previous calls to wait_until() may have accumulated state that would be lost when returning EINTR to userspace.)
It is up to the caller (the “waiter”) to make sure that it synchronizes with any object
that triggers an event (the “notifier”). This Waiter does not provide any synchronization
itself. Note that synchronization between the “waiter” the “notifier” may be provided by
the EventHandler used to handle an event iff the waiter observes the side-effects of
the handler (e.g. reading the ready list modified by EventHandler::Enqueue or
[EventHandler::EnqueueOnce]).
pub fn wake_immediately(&self, events: FdEvents, handler: EventHandler)
Sourcepub fn wake_on_zircon_signals(
&self,
handle: &dyn AsHandleRef,
zx_signals: Signals,
handler: SignalHandler,
) -> Result<PortWaitCanceler, Status>
pub fn wake_on_zircon_signals( &self, handle: &dyn AsHandleRef, zx_signals: Signals, handler: SignalHandler, ) -> Result<PortWaitCanceler, Status>
Establish an asynchronous wait for the signals on the given Zircon handle (not to be confused with POSIX signals), optionally running a FnOnce.
Returns a PortWaitCanceler that can be used to cancel the wait.
Sourcepub fn fake_wait(&self) -> WaitCanceler
pub fn fake_wait(&self) -> WaitCanceler
Return a WaitCanceler representing a wait that will never complete. Useful for stub implementations that should block forever even though a real implementation would wake up eventually.
pub fn notify(&self)
Sourcepub fn interrupt(&self)
pub fn interrupt(&self)
Interrupt the waiter to deliver a signal. The wait operation will return EINTR, and a typical caller should then unwind to the syscall dispatch loop to let the signal be processed. See wait_until() for more details.
Ignored if the waiter was created with new_ignoring_signals().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Waiter
impl !RefUnwindSafe for Waiter
impl Send for Waiter
impl Sync for Waiter
impl Unpin for Waiter
impl !UnwindSafe for Waiter
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [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