ckb_metrics::core

Trait Atomic

Source
pub trait Atomic: Send + Sync {
    type T: Number;

    // Required methods
    fn new(val: Self::T) -> Self;
    fn set(&self, val: Self::T);
    fn get(&self) -> Self::T;
    fn inc_by(&self, delta: Self::T);
    fn dec_by(&self, delta: Self::T);
}
Expand description

An interface for atomics. Used to generically model float metrics and integer metrics, i.e. Counter and IntCounter.

Required Associated Types§

Source

type T: Number

The numeric type associated with this atomic.

Required Methods§

Source

fn new(val: Self::T) -> Self

Create a new atomic value.

Source

fn set(&self, val: Self::T)

Set the value to the provided value.

Source

fn get(&self) -> Self::T

Get the value.

Source

fn inc_by(&self, delta: Self::T)

Increment the value by a given amount.

Source

fn dec_by(&self, delta: Self::T)

Decrement the value by a given amount.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§