data.counter ≡
template <auto Maximum, auto Initial = 0> class counter §source
A thread-safe counter that can be incremented in one location and decremented in another.
Parameters
-
auto MaximumThe maximum count value.
-
auto Initial = 0
The initial value of the counter.
Methods
-
inline void reset() §source
Reset the counter to the initial state.
-
inline counter::ctr_t count() §source
Return the current count.
-
inline bool is_zero() §source
Returns
count() == 0. Optimized to reduce the number of resources required. -
inline void increment() §source
Add one to the counter.
-
inline void add(counter::ctr_t amount) §source
Add amount to the counter.
-
inline void decrement() §source
Subtract one from the counter.
-
inline void subtract(counter::ctr_t amount) §source
Subtract amount from the counter.