pub enum WaitStrategy {
BusySpin,
YieldSpin,
BackoffSpin,
Adaptive {
spin_iters: u32,
yield_iters: u32,
},
MonitorWaitFallback,
}Expand description
Strategy for blocking recv().
All variants are no_std compatible — no OS thread primitives required.
| Strategy | Latency | CPU usage | Best for |
|---|---|---|---|
BusySpin | Lowest (~0 ns wakeup) | 100% core | Dedicated, pinned cores |
YieldSpin | Low (~30 ns on x86) | High | Shared cores, SMT |
BackoffSpin | Medium (exponential) | Decreasing | Background consumers |
Adaptive | Auto-scaling | Varies | General purpose |
MonitorWaitFallback | Near-zero (~30 ns on Intel) | Near-zero | Intel Alder Lake+ |
Variants§
BusySpin
Pure busy-spin with no PAUSE instruction. Minimum wakeup latency but consumes 100% of one CPU core. Use on dedicated, pinned cores.
YieldSpin
Spin with core::hint::spin_loop() (PAUSE on x86, YIELD on ARM)
between iterations. Yields the CPU pipeline to the SMT sibling
and reduces power consumption vs BusySpin.
BackoffSpin
Exponential backoff spin. Starts with bare spins, then escalates to PAUSE-based spins with increasing delays. Good for consumers that may be idle for extended periods without burning a full core.
Adaptive
Three-phase escalation: bare spin for spin_iters iterations,
then PAUSE-spin for yield_iters, then repeated PAUSE bursts.
Fields
MonitorWaitFallback
TPAUSE on Intel (Tremont+, Alder Lake+) or WFE on ARM.
On x86_64 with WAITPKG support: TPAUSE puts the core into an
optimized C0.1 state for a bounded interval, giving near-zero power
consumption with ~30 ns wakeup latency. It monitors no address, which
is what makes it safe to offer — a variant taking an address to watch
cannot be constructed safely.
Falls back to YieldSpin on x86 CPUs without WAITPKG support.
On aarch64: uses SEVL+WFE (identical to YieldSpin).
On x86_64 with WAITPKG: TPAUSE (timed wait in C0.1 state) for
low-power waiting. On aarch64: SEVL+WFE. On other x86: PAUSE.
Trait Implementations§
Source§impl Clone for WaitStrategy
impl Clone for WaitStrategy
Source§fn clone(&self) -> WaitStrategy
fn clone(&self) -> WaitStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WaitStrategy
Source§impl Debug for WaitStrategy
impl Debug for WaitStrategy
Source§impl Default for WaitStrategy
impl Default for WaitStrategy
impl Eq for WaitStrategy
Source§impl PartialEq for WaitStrategy
impl PartialEq for WaitStrategy
impl StructuralPartialEq for WaitStrategy
Auto Trait Implementations§
impl Freeze for WaitStrategy
impl RefUnwindSafe for WaitStrategy
impl Send for WaitStrategy
impl Sync for WaitStrategy
impl Unpin for WaitStrategy
impl UnsafeUnpin for WaitStrategy
impl UnwindSafe for WaitStrategy
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.