pub struct Meter<'a> { /* private fields */ }Expand description
The counter an algorithm ticks: a Control and the steps taken.
tick is the step: it asks the budget, then the poll,
and counts the step only if neither stops it. A parallel pass gives
each item a split and afterwards
charges the items’ steps in the sequential order, so
both builds stop on the same item with the same count (ADR-0030 §4).
Implementations§
Source§impl<'a> Meter<'a>
impl<'a> Meter<'a>
Sourcepub fn tick(&mut self) -> Result<(), Interrupted>
pub fn tick(&mut self) -> Result<(), Interrupted>
One step. Err when the budget is spent (checked first, and the
poll is then not asked) or the poll answers true; the step is not
counted, so Interrupted::steps is the steps completed.
Sourcepub fn stopped(&self) -> Option<Interrupted>
pub fn stopped(&self) -> Option<Interrupted>
The first stop tick reported, if any. A caller
that runs code which may turn a failed step into a failure of its
own (an attempt that falls back to another) asks this at its end:
an operation that saw a stop is stopped, whatever else it
returned.
Sourcepub fn split(&self) -> Meter<'a>
pub fn split(&self) -> Meter<'a>
The meter for one item of a parallel pass: the same poll, no steps yet, capped at the budget this meter has left.
Sourcepub fn charge(&mut self, steps: u64) -> Result<(), Interrupted>
pub fn charge(&mut self, steps: u64) -> Result<(), Interrupted>
Takes the steps of one item of a pass this meter was
split for. Items are charged in the sequential
order; the first whose running total crosses the budget is
Err(Interrupted { by: Stop::Budget, steps: budget }), which is
what the sequential build’s own tick reports there.
Sourcepub fn charge_stop(&mut self, item: Interrupted) -> Interrupted
pub fn charge_stop(&mut self, item: Interrupted) -> Interrupted
The Interrupted of an item that stopped itself, as this meter
reports it: the item’s steps added to the ones already charged (and
no more than the budget), so the count is the sequential build’s. An item that finished is
charged; one that stopped is charged here
instead, never both.
Trait Implementations§
impl<'a> Copy for Meter<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Meter<'a>
impl<'a> !UnwindSafe for Meter<'a>
impl<'a> Freeze for Meter<'a>
impl<'a> Send for Meter<'a>
impl<'a> Sync for Meter<'a>
impl<'a> Unpin for Meter<'a>
impl<'a> UnsafeUnpin for Meter<'a>
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.