Trait penumbra_app::metrics::CounterFn

pub trait CounterFn {
    // Required methods
    fn increment(&self, value: u64);
    fn absolute(&self, value: u64);
}
Expand description

A counter handler.

Required Methods§

fn increment(&self, value: u64)

Increments the counter by the given amount.

fn absolute(&self, value: u64)

Sets the counter to at least the given amount.

This is intended to support use cases where multiple callers are attempting to synchronize this counter with an external counter that they have no control over. As multiple callers may read that external counter, and attempt to set it here, there could be reordering issues where a caller attempts to set an older (smaller) value after the counter has been updated to the latest (larger) value.

This method must cope with those cases. An example of doing so atomically can be found in AtomicCounter.

Implementations on Foreign Types§

§

impl<T> CounterFn for Arc<T>
where T: CounterFn,

§

fn increment(&self, value: u64)

§

fn absolute(&self, value: u64)

Implementors§