pub struct UntilElapsedPolicy {
pub min_ms: u64,
pub delta: u64,
}Expand description
Extend while ctx.elapsed_ms < min_ms, projecting the
remaining work from the observed rate and committing it in
one batch.
Per call: estimate repeats = floor((consumed * remaining_ms / elapsed_ms) / base) — the number of base-sized passes
needed to fill the time remaining at the current rate. Apply
a 5% under-bias (repeats * 95 / 100) so successive
extensions converge from below the target rather than
overshooting once. Commit repeats * base cycles.
The under-bias gives a geometric convergence: each call
covers ~95% of the time remaining, so 3–4 calls typically
land within 0.01% of the time budget. The first call (no
rate signal yet — elapsed_ms == 0 or consumed == 0)
falls back to one base chunk via the delta field.
Fields§
§min_ms: u64The elapsed milliseconds to reach.
delta: u64The extension step for the first call, before a rate is known.
Trait Implementations§
Source§impl ExtensionPolicy for UntilElapsedPolicy
impl ExtensionPolicy for UntilElapsedPolicy
Source§fn next_extension(&self, ctx: &ExtensionContext) -> Option<u64>
fn next_extension(&self, ctx: &ExtensionContext) -> Option<u64>
Auto Trait Implementations§
impl Freeze for UntilElapsedPolicy
impl RefUnwindSafe for UntilElapsedPolicy
impl Send for UntilElapsedPolicy
impl Sync for UntilElapsedPolicy
impl Unpin for UntilElapsedPolicy
impl UnsafeUnpin for UntilElapsedPolicy
impl UnwindSafe for UntilElapsedPolicy
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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