|
Zero
0.1.0
|
An atomic counter that avoids using locks. More...
#include <AtomicCounter.hpp>
Public Member Functions | |
| Atomic () | |
| Atomic (T counter) | |
| T | incThenFetch () |
| T | decThenFetch () |
| T | addThenFetch (T amount) |
| bool | isZero () const |
| operator T () const | |
| T | load () const |
| void | store (T t) |
| T | operator= (T amount) |
| Assignement. More... | |
| T | exchange (T t) |
| bool | compare_exchange_strong (T *expected, T desired) |
| T | fetch_add (T amount) |
| T | fetch_sub (T amount) |
| T | fetch_or (T amount) |
| T | fetch_and (T amount) |
| T | fetch_xor (T amount) |
| T | operator+= (T amount) |
| T | operator-= (T amount) |
| T | operator|= (T amount) |
| T | operator &= (T amount) |
| T | operator^= (T amount) |
| T | operator++ (int) |
| T | operator-- (int) |
| T | operator++ () |
| T | operator-- () |
Private Member Functions | |
| Atomic (const Atomic &) | |
| Copy construction is forbidden. More... | |
| Atomic & | operator= (const Atomic &) |
| Copy assignment is forbidden. More... | |
Private Attributes | |
| T | counter |
An atomic counter that avoids using locks.
Encapsulates an atomic counter. Be wary when using it so as to not inadvertently introduce a race–the value may change at any time outside of the defined operations.
If you really need the current value, then fetchThenAdd(0). Beware that the returned value may immediatly become out of date!
|
inline |
|
inlineexplicit |
|
private |
Copy construction is forbidden.
|
inline |
Adds amount to the counter and then returns the value C11/C++11 have no such function. Use operator += instead
|
inline |
|
inline |
Decrements the counter and then returns the value C11/C++11 have no such function. Use prefix operator--() instead
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Increments the counter and then returns the value C11/C++11 have no such function. Use prefix operator++() instead
|
inline |
Returns true if the counter is zero C11/C++11 have no such function. Use operator T() instead
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Assignement.
|
private |
Copy assignment is forbidden.
|
inline |
|
inline |
|
inline |
|
private |
1.8.12