18 #include <boost/static_assert.hpp>
20 #include "mongo/base/disallow_copying.h"
21 #include "mongo/platform/atomic_intrinsics.h"
22 #include "mongo/platform/compiler.h"
46 template <
typename _WordType>
95 WordType
swap(WordType newValue) {
156 volatile WordType _value;
159 #define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
160 typedef class AtomicWord<WTYPE> NAME; \
162 BOOST_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); \
165 _ATOMIC_WORD_DECLARE(AtomicUInt32,
unsigned);
166 _ATOMIC_WORD_DECLARE(AtomicUInt64,
unsigned long long);
167 _ATOMIC_WORD_DECLARE(AtomicInt32,
int);
168 _ATOMIC_WORD_DECLARE(AtomicInt64,
long long);
169 #undef _ATOMIC_WORD_DECLARE
WordType load() const
Gets the current value of this AtomicWord.
Definition: atomic_word_intrinsics.h:66
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
WordType loadRelaxed() const
Gets the current value of this AtomicWord.
Definition: atomic_word_intrinsics.h:75
_WordType WordType
Underlying value type.
Definition: atomic_word_intrinsics.h:54
WordType compareAndSwap(WordType expected, WordType newValue)
Atomic compare and swap.
Definition: atomic_word_intrinsics.h:107
WordType addAndFetch(WordType increment)
Get the current value of this, add "increment" and store it, atomically.
Definition: atomic_word_intrinsics.h:140
AtomicWord(WordType value=WordType(0))
Construct a new word with the given initial value.
Definition: atomic_word_cxx11.h:60
WordType fetchAndSubtract(WordType decrement)
Get the current value of this, subtract "decrement" and store it, atomically.
Definition: atomic_word_intrinsics.h:129
WordType swap(WordType newValue)
Atomically swaps the current value of this with "newValue".
Definition: atomic_word_intrinsics.h:95
WordType subtractAndFetch(WordType decrement)
Get the current value of this, subtract "decrement" and store it, atomically.
Definition: atomic_word_intrinsics.h:151
WordType fetchAndAdd(WordType increment)
Get the current value of this, add "increment" and store it, atomically.
Definition: atomic_word_intrinsics.h:118
Instantiation of AtomicIntrinsics<> for all word types T.
Definition: atomic_intrinsics_gcc_atomic.h:29
void store(WordType newValue)
Sets the value of this AtomicWord to "newValue".
Definition: atomic_word_intrinsics.h:84