pub struct WindowController { /* private fields */ }Expand description
Shared admission gate for one band’s closed-loop workers.
Implementations§
Source§impl WindowController
impl WindowController
Sourcepub fn new(config: &BandConfig) -> Self
pub fn new(config: &BandConfig) -> Self
Build the controller for config. The window opens at offset 0.0;
callers pass offsets measured from the first sampled request’s origin.
Sourcepub fn with_bounds(min_samples: usize, min_wall_s: f64) -> Self
pub fn with_bounds(min_samples: usize, min_wall_s: f64) -> Self
A controller with explicit bounds, for the warmup phase (§4.4.2: exactly
2 × c requests, no wall-clock floor) and for tests.
Sourcepub fn try_admit(&mut self, now_s: f64) -> Option<usize>
pub fn try_admit(&mut self, now_s: f64) -> Option<usize>
§4.4.2 — “termination is whichever bound is satisfied last”.
Returns the index reserved for a new request, or None once the window
has closed. §4.4.7: no new request is issued at or after T, and T
is stamped here, once, at the first refusal.
Sourcepub fn try_admit_with_in_flight(&mut self, now_s: f64) -> Option<(usize, usize)>
pub fn try_admit_with_in_flight(&mut self, now_s: f64) -> Option<(usize, usize)>
Self::try_admit, also returning the in-flight count including this
request, read under the same lock that made the admission decision.
A caller that admits, unlocks, and then asks for in_flight() reads a
number from a different instant. The per-request in-flight figure is the
evidence that the client was concurrent, so it must not be a racy guess.
Sourcepub fn complete(&mut self, now_s: f64) -> bool
pub fn complete(&mut self, now_s: f64) -> bool
Record a completion at now_s. Returns true when this request
completed during the drain, i.e. after the window closed.
Sourcepub fn peak_in_flight(&self) -> usize
pub fn peak_in_flight(&self) -> usize
Peak concurrent requests the client had in flight. This is the client’s
number and is named as such: max_in_flight in §4.4.9 is what the
server admitted, which only the server can report.
Sourcepub fn report(&self) -> WindowReport
pub fn report(&self) -> WindowReport
Finalise the band. window_close_s defaults to the last completion when
the window never closed (a run cut short), which yields drain_ms = 0
rather than a negative number.
Trait Implementations§
Source§impl Clone for WindowController
impl Clone for WindowController
Auto Trait Implementations§
impl Freeze for WindowController
impl RefUnwindSafe for WindowController
impl Send for WindowController
impl Sync for WindowController
impl Unpin for WindowController
impl UnsafeUnpin for WindowController
impl UnwindSafe for WindowController
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more