pub struct WatermarkController<C: Clock = MonotonicClock> { /* private fields */ }Expand description
Per-pipeline-thread pause/resume state machine with hysteresis.
WatermarkController::tick returns a Transition and the driver
applies it; the controller calls nothing itself. Transitions strictly
alternate (Pause, Resume, Pause, …) and each full cycle takes at
least BackpressureParams::min_pause.
Implementations§
Source§impl WatermarkController<MonotonicClock>
impl WatermarkController<MonotonicClock>
Sourcepub fn new(params: BackpressureParams) -> Self
pub fn new(params: BackpressureParams) -> Self
Controller on the real monotonic clock.
Source§impl<C: Clock> WatermarkController<C>
impl<C: Clock> WatermarkController<C>
Sourcepub fn with_clock(params: BackpressureParams, clock: C) -> Self
pub fn with_clock(params: BackpressureParams, clock: C) -> Self
Controller with an injected clock (tests).
Sourcepub fn on_send_rejected(&mut self)
pub fn on_send_rejected(&mut self)
Record that a try_send to a downstream queue was rejected. Cheap;
call from the poll loop’s rejection path. While paused this restarts
the minimum-pause timer.
Sourcepub fn tick(
&mut self,
budget: &InflightBudget,
queues_below_low: bool,
) -> Option<Transition>
pub fn tick( &mut self, budget: &InflightBudget, queues_below_low: bool, ) -> Option<Transition>
Evaluate the state machine once per poll iteration.
queues_below_low is the driver’s view of its downstream queues
(all below the low-watermark fill ratio). Returns a transition for
the driver to apply, or None.
Sourcepub fn params(&self) -> &BackpressureParams
pub fn params(&self) -> &BackpressureParams
The hysteresis parameters in force.