Skip to main content

Meter

Struct Meter 

Source
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>

Source

pub fn new(control: &Control<'a>) -> Self

A meter at zero steps under control.

Source

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.

Source

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.

Source

pub fn steps(&self) -> u64

The steps taken so far.

Source

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.

Source

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.

Source

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§

Source§

impl<'a> Clone for Meter<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Meter<'a>

Source§

impl Debug for Meter<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Meter<'_>

Source§

fn default() -> Self

A meter that never stops: Control::NONE’s.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.