pub struct AtomicWaker { /* private fields */ }Expand description
Utility struct to register and wake a waker.
Single-slot waker coordinated by an atomic state machine. Unlike
CriticalSectionWaker, wake() does not
enter a critical section, which avoids unnecessary jitter on higher-priority
interrupts and improves wake latency for time-critical async drivers.
If a waker is registered, registering a different waker replaces the
previous one and wakes it, giving the displaced task a chance to
re-register itself. This matches the semantics of
WakerRegistration; note that
GenericAtomicWaker and
CriticalSectionWaker instead replace the
previous waker without waking it.
Intended to wake a single task from an interrupt handler.
On targets without 32-bit atomic CAS support (e.g. Xtensa S2, AVR, RV32I),
AtomicWaker is a type alias for
CriticalSectionWaker, since the lockless
state machine relies on compare_exchange/swap/fetch_or.
Implementations§
Source§impl AtomicWaker
impl AtomicWaker
Sourcepub fn register(&self, waker: &Waker)
pub fn register(&self, waker: &Waker)
Register a waker.
If a different waker was previously registered, it is replaced and
woken so the displaced task can re-register itself if it is still
interested. This matches
WakerRegistration::register.
If a wake call is in flight when this is called, the
supplied waker is woken directly to schedule a re-poll.
Sourcepub fn wake(&self)
pub fn wake(&self)
Wake the registered waker, if any.
The stored waker is invoked via Waker::wake_by_ref and remains
registered, matching the semantics of
CriticalSectionWaker.
Trait Implementations§
Source§impl Default for AtomicWaker
Available on target_has_atomic=32 only.
impl Default for AtomicWaker
target_has_atomic=32 only.impl Send for AtomicWaker
target_has_atomic=32 only.impl Sync for AtomicWaker
target_has_atomic=32 only.