Useful for threadsafe smart pointers (and probably other stuff too).
Currently implemented in terms of the __exchange_and_add and __atomic_add functions in libstdc++.
Public Methods | |
| atomic (int val=0) | |
| Constructs an atomic integer with a given initial value. | |
| word | exchange_and_add (int addend) |
| Atomically increases the value of the integer and returns its old value. | |
| void | add (int addend) |
| Atomically increases the value of the integer. | |
| void | operator+= (int addend) |
| Atomically increases the value of the integer. | |
| void | operator-= (int addend) |
| Atomically decreases the value of the integer. | |
| void | operator++ () |
| Atomically increments the value of the integer. | |
| void | operator-- () |
| Atomically decrements the value of the integer. | |
| int | operator++ (int) |
| Atomically increments the value of the integer and returns its old value. | |
| int | operator-- (int) |
| Atomically decrements the value of the integer and returns its old value. | |
| operator int () const | |
| Returns the value of the integer. | |
|
|
Constructs an atomic integer with a given initial value.
|
|
|
Atomically increases the value of the integer.
|
|
|
Atomically increases the value of the integer and returns its old value.
|
|
|
Returns the value of the integer.
|
|
|
Atomically increments the value of the integer and returns its old value.
|
|
|
Atomically increments the value of the integer.
|
|
|
Atomically increases the value of the integer.
|
|
|
Atomically decrements the value of the integer and returns its old value.
|
|
|
Atomically decrements the value of the integer.
|
|
|
Atomically decreases the value of the integer.
|