mn::atomic_counter Class Reference
This class implements a simple counter, whit atomic operations for use in a multithreaded environment. More...
#include <mn_atomic_counter.hpp>
Collaboration diagram for mn::atomic_counter:
Public Types | |
using | value_type = int |
Public Member Functions | |
atomic_counter () | |
Construct a new atomic_counter and initializes it to zero. More... | |
atomic_counter (const value_type &value) | |
Construct a new atomic_counter and initializes it with the given value. More... | |
atomic_counter (const atomic_counter &other) | |
Construct a new atomic_counter from a other atomic_counter. More... | |
operator value_type () const | |
Converts the atomic_counter to value_type. More... | |
value_type | value () const |
Get the value of the counter. More... | |
value_type | operator++ () |
Increments the counter. More... | |
value_type | operator-- () |
Decrements the counter. More... | |
value_type | operator++ (int) |
Increments the counter. More... | |
value_type | operator-- (int) |
Decrements the counter. More... | |
bool | operator! () const |
If the counter zero? More... | |
atomic_counter & | operator= (const atomic_counter &other) |
Assigns the value of another atomic_counter. More... | |
atomic_counter & | operator= (const value_type &value) |
Assigns a value to the counter. More... | |
Private Attributes | |
_atomic< value_type > | m_atomicCount |
Detailed Description
This class implements a simple counter, whit atomic operations for use in a multithreaded environment.
Member Typedef Documentation
◆ value_type
using mn::atomic_counter::value_type = int |
Constructor & Destructor Documentation
◆ atomic_counter() [1/3]
mn::atomic_counter::atomic_counter | ( | ) |
Construct a new atomic_counter and initializes it to zero.
◆ atomic_counter() [2/3]
mn::atomic_counter::atomic_counter | ( | const value_type & | value | ) |
Construct a new atomic_counter and initializes it with the given value.
- Parameters
-
value The start value for this the counter.
◆ atomic_counter() [3/3]
mn::atomic_counter::atomic_counter | ( | const atomic_counter & | other | ) |
Construct a new atomic_counter from a other atomic_counter.
- Parameters
-
other The other counter from copyed it.
Member Function Documentation
◆ operator value_type()
|
inline |
Converts the atomic_counter to value_type.
◆ operator!()
|
inline |
If the counter zero?
- Returns
- If true the counter is zero and if false otherwise.
◆ operator++() [1/2]
|
inline |
Increments the counter.
- Returns
- The result of the increment.
◆ operator++() [2/2]
|
inline |
Increments the counter.
- Returns
- The previous value.
◆ operator--() [1/2]
|
inline |
Decrements the counter.
- Returns
- The result of the decrement.
◆ operator--() [2/2]
|
inline |
Decrements the counter.
- Returns
- The previous value.
◆ operator=() [1/2]
atomic_counter & mn::atomic_counter::operator= | ( | const atomic_counter & | other | ) |
Assigns the value of another atomic_counter.
◆ operator=() [2/2]
atomic_counter & mn::atomic_counter::operator= | ( | const value_type & | value | ) |
Assigns a value to the counter.
- Parameters
-
value The value for assigns the counter.
◆ value()
|
inline |
Get the value of the counter.
- Returns
- The value of the counter.
Member Data Documentation
◆ m_atomicCount
|
private |
The documentation for this class was generated from the following files: