Struct global_counter::primitive::fast::FlushingCounterIsize[][src]

pub struct FlushingCounterIsize { /* fields omitted */ }

A flushing counter.

This counter is intended to be used in one specific way:

  • First, all counting threads increment the counter.
  • Every counting thread calls flush after it is done incrementing.
  • After every flush is guaranteed to have been executed, get will return the exact amount of times inc has been called (+ the start offset).

In theory, this counter is equivalent to an approximate counter with its resolution set to infinity.

Note that this counters inc - flush - get - path does not induce a happens-before relationship, as defined by the C++ standard. In other words, it is not safe to rely solely on this counter for the synchronization of external data. The most important example of this is spinning until a certain value is reached, which does not guarantee any other operations to be visible to the reading thread.

Implementations

impl FlushingCounterIsize[src]

pub const fn new(start: isize) -> Self[src]

Creates a new counter, with the given starting value. Can be used in static contexts.

pub fn inc(&self)[src]

Increments the counter by one.

pub fn get(&self) -> isize[src]

Gets the current value of the counter. This only returns the correct value after all local counters have been flushed.

pub fn flush(&self)[src]

Flushes the local counter to the global.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.