pub enum WaitStrategy {
BusySpin,
YieldSpin,
Park,
Adaptive {
spin_iters: u32,
yield_iters: u32,
},
}Expand description
Strategy for blocking recv() and SubscriberGroup::recv().
Controls how the consumer thread waits when no message is available. Choose based on your latency vs CPU usage requirements:
| Strategy | Latency | CPU usage | Best for |
|---|---|---|---|
BusySpin | Lowest (~0 ns wakeup) | 100% core | HFT, dedicated cores |
YieldSpin | Low (~1-5 us wakeup) | High | Shared cores, SMT |
Park | Medium (~10-50 us wakeup) | Near zero | Background consumers |
Adaptive | Auto-scaling | Varies | General purpose |
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 thread::yield_now() between iterations. Yields the
OS time slice to other threads on the same core. Good for SMT.
Park
thread::park() / unpark() based waiting. Near-zero CPU usage
when idle but higher wakeup latency (~10-50 us depending on OS).
Adaptive
Three-phase escalation: busy-spin for spin_iters iterations,
then yield for yield_iters, then park. Balances latency and CPU.
On no_std (without the std feature), the yield and park phases
fall back to core::hint::spin_loop().
Trait Implementations§
Source§impl Clone for WaitStrategy
impl Clone for WaitStrategy
Source§fn clone(&self) -> WaitStrategy
fn clone(&self) -> WaitStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WaitStrategy
impl Debug for WaitStrategy
Source§impl Default for WaitStrategy
impl Default for WaitStrategy
Source§impl PartialEq for WaitStrategy
impl PartialEq for WaitStrategy
impl Copy for WaitStrategy
impl Eq 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.