WaitStrategy

Trait WaitStrategy 

Source
pub trait WaitStrategy {
    // Required methods
    fn reset(&mut self);
    fn wait(&mut self);
}
Expand description

Progressive backoff when polling.

This trait is intentionally minimal and no_std-friendly. It is typically used at the edges (router loops, receive loops) to avoid busy-spinning.

§Contract

  • Implementations should be cheap and panic-free.
  • wait may spin, yield, or sleep depending on the strategy.
  • Callers should treat wait as a hint; it does not guarantee that the observed condition will change.

Required Methods§

Source

fn reset(&mut self)

Reset internal counters to the initial (most aggressive) state.

Source

fn wait(&mut self)

Perform one backoff step (spin/yield/sleep depending on implementation).

Implementors§

Source§

impl WaitStrategy for SpinWait

Source§

impl WaitStrategy for StdBackoff

Available on crate feature std only.
Source§

impl WaitStrategy for YieldWait

Available on crate feature std only.