Struct prometheus_utils::Windowing
source · [−]pub struct Windowing<P> { /* private fields */ }
Expand description
Windowing
is a mechanism for rotating between different observations.
It provides an accessor Windowing::current
for the current
observation, and a method Windowing::cycle_windows
which makes the
next observation in the ring current, and returns the observation which
was current prior to the call.
Implementations
sourceimpl<P: Default> Windowing<P>
impl<P: Default> Windowing<P>
sourcepub fn new() -> Self
pub fn new() -> Self
Constructor. Initializes its owned ring of P
s using Default::default()
.
sourcepub fn current(&self) -> &P
pub fn current(&self) -> &P
Get the current collection. The underling P
is expected to be
cycled on some regular interval.
Data integrity guarantees are weak. In some circumstances, the
returned P
window may be for the prior interval, if whatever wants
to write a datapoint races with something replacing the current P
.
It is even possible (if extremely unlikely) for a value to be written
into an old P
collection, if the writer races with a reader and
writes after the reader has emptied the collection and released its
lock.
sourcepub fn cycle_windows(&self) -> &P
pub fn cycle_windows(&self) -> &P
Cycle to the next window. Returns the window which was active before the call.
Auto Trait Implementations
impl<P> RefUnwindSafe for Windowing<P> where
P: RefUnwindSafe,
impl<P> Send for Windowing<P> where
P: Send,
impl<P> Sync for Windowing<P> where
P: Sync,
impl<P> Unpin for Windowing<P>
impl<P> UnwindSafe for Windowing<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more