|
Click
|
A 64-bit integer with support for atomic operations. More...
#include <atomic.hh>
Public Member Functions | |
| uint64_t | value () const |
| Return the value. | |
| uint64_t | nonatomic_value () const |
| Return the value. | |
| operator uint64_t () const | |
| Return the value. | |
| atomic_uint64_t & | operator= (uint64_t x) |
| Set the value to x. | |
| atomic_uint64_t & | operator+= (int64_t delta) |
| Atomically add delta to the value. | |
| atomic_uint64_t & | operator-= (int64_t delta) |
| Atomically subtract delta from the value. | |
| void | nonatomic_inc () |
| Increment the value. | |
| void | operator++ () |
| Atomically increment the value. | |
| void | operator++ (int) |
| Atomically increment the value. | |
| void | nonatomic_dec () |
| Decrement the value. | |
| void | operator-- () |
| Atomically decrement the value. | |
| void | operator-- (int) |
| Atomically decrement the value. | |
| uint64_t | compare_swap (uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED |
| uint64_t | fetch_and_add (uint64_t delta) |
| Perform a compare-and-swap operation. | |
Static Public Member Functions | |
| static void | add (volatile uint64_t &x, uint64_t delta) |
| Atomically increment value x. | |
| static uint64_t | compare_swap (volatile uint64_t &x, uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED |
| static bool | use_builtins () |
A 64-bit integer with support for atomic operations.
The atomic_uint64_t class represents a 64-bit integer, with support for atomic operations. The +=, -=, &=, |=, ++, and – operations are implemented using atomic instructions. There are also atomic swap(), fetch_and_add(), dec_and_test(), and compare_swap() operations.
Because of some issues with compiler implementations, atomic_uint64_t has no explicit constructor; to set an atomic_uint64_t to a value, use operator=.
The atomic_uint64_t only provides true atomic semantics when that has been implemented. It has been implemented in the Linux kernel, and at userlevel (when –enable-multithread has been defined) for x86 machines. In other situations, it's not truly atomic (because it doesn't need to be).
|
inline |
Return the value.
|
inline |
Return the value.
|
inline |
Return the value.
|
inline |
Set the value to x.
|
inline |
Atomically add delta to the value.
|
inline |
Atomically subtract delta from the value.
|
inline |
Increment the value.
|
inline |
Atomically increment the value.
|
inline |
Atomically increment the value.
|
inline |
Decrement the value.
|
inline |
Atomically decrement the value.
|
inline |
Atomically decrement the value.
|
inline |
Perform a compare-and-swap operation.
| x | value |
| expected | test value |
| desired | new value |
Behaves like this, but in one atomic step:
Also acts as a memory barrier.
Atomically add delta to the value, returning the old value.
Behaves like this, but in one atomic step:
|
inlinestatic |
Atomically increment value x.