Trait atomic_counter::AtomicCounter[][src]

pub trait AtomicCounter: Send + Sync {
    type PrimitiveType;
    fn inc(&self) -> Self::PrimitiveType;
fn add(&self, amount: Self::PrimitiveType) -> Self::PrimitiveType;
fn get(&self) -> Self::PrimitiveType;
fn reset(&self) -> Self::PrimitiveType;
fn into_inner(self) -> Self::PrimitiveType; }

Provides an atomic counter trait that can be shared across threads.

Associated Types

Underlying primitive type that is being shared atomically.

Required Methods

Atomically increments the counter by one, returning the previous value.

Atomically increments the counter by amount, returning the previous value.

Atomically gets the current value of the counter, without modifying the counter.

Atomically returns the current value of the counter, while resetting to count to zero.

Consume the atomic counter and return the primitive type.

This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Implementors