data.counter


template <auto Maximum, auto Initial = 0>
class counter §

A thread-safe counter that can be incremented in one location and decremented in another.

Parameters

  • auto Maximum
    

    The maximum count value.

  • auto Initial = 0
    

    The initial value of the counter.

Aliases

Methods

  • inline void reset() §
    

    Reset the counter to the initial state.

  • inline counter::ctr_t count() §
    

    Return the current count.

  • inline bool is_zero() §
    

    Returns count() == 0. Optimized to reduce the number of resources required.

  • inline void increment() §
    

    Add one to the counter.

  • inline void add(counter::ctr_t amount) §
    

    Add amount to the counter.

  • inline void decrement() §
    

    Subtract one from the counter.

  • inline void subtract(counter::ctr_t amount) §
    

    Subtract amount from the counter.