MongoDB C++ Driver
legacy-1.1.2
|
Implementation of the AtomicWord interface in terms of the C++11 Atomics. More...
#include <atomic_word_cxx11.h>
Public Types | |
typedef _WordType | WordType |
Underlying value type. | |
typedef _WordType | WordType |
Underlying value type. | |
Public Member Functions | |
AtomicWord (WordType value=WordType(0)) | |
Construct a new word with the given initial value. | |
WordType | load () const |
Gets the current value of this AtomicWord. More... | |
WordType | loadRelaxed () const |
Gets the current value of this AtomicWord. More... | |
void | store (WordType newValue) |
Sets the value of this AtomicWord to "newValue". More... | |
WordType | swap (WordType newValue) |
Atomically swaps the current value of this with "newValue". More... | |
WordType | compareAndSwap (WordType expected, WordType newValue) |
Atomic compare and swap. More... | |
WordType | fetchAndAdd (WordType increment) |
Get the current value of this, add "increment" and store it, atomically. More... | |
WordType | fetchAndSubtract (WordType decrement) |
Get the current value of this, subtract "decrement" and store it, atomically. More... | |
WordType | addAndFetch (WordType increment) |
Get the current value of this, add "increment" and store it, atomically. More... | |
WordType | subtractAndFetch (WordType decrement) |
Get the current value of this, subtract "decrement" and store it, atomically. More... | |
AtomicWord (WordType value=WordType(0)) | |
Construct a new word with the given initial value. | |
WordType | load () const |
Gets the current value of this AtomicWord. More... | |
WordType | loadRelaxed () const |
Gets the current value of this AtomicWord. More... | |
void | store (WordType newValue) |
Sets the value of this AtomicWord to "newValue". More... | |
WordType | swap (WordType newValue) |
Atomically swaps the current value of this with "newValue". More... | |
WordType | compareAndSwap (WordType expected, WordType newValue) |
Atomic compare and swap. More... | |
WordType | fetchAndAdd (WordType increment) |
Get the current value of this, add "increment" and store it, atomically. More... | |
WordType | fetchAndSubtract (WordType decrement) |
Get the current value of this, subtract "decrement" and store it, atomically. More... | |
WordType | addAndFetch (WordType increment) |
Get the current value of this, add "increment" and store it, atomically. More... | |
WordType | subtractAndFetch (WordType decrement) |
Get the current value of this, subtract "decrement" and store it, atomically. More... | |
Implementation of the AtomicWord interface in terms of the C++11 Atomics.
Template type for word types supporting indivisible memory operations, implemented in terms of the atomic_intrinsics header.
Effects of operations with "acquire" semantics are visible to other threads before effects of any subsequent operation by the calling thread. Effects of operations with "release" semantics are visible to other processors only after the effects of previous operations on the current thread are visible.
NOTE(schwerin): This implementation assumes that instances are naturally aligned. Instances that are not naturally aligned may operate incorrectly, or not at all. Natural alignment for this purpose means that the byte address of the beginning of the object is an integer multiple of the size of the type, in bytes.
NOTE(schwerin): This is a low level concurrency type, it is very hard to use correctly, and you should not decide to use it lightly.
NOTE(schwerin): This type is and must be a POD type, or per C++11 rules, a "Standard-layout" type.
|
inline |
Get the current value of this, add "increment" and store it, atomically.
Returns the value of this after incrementing.
Has acquire and release semantics.
|
inline |
Get the current value of this, add "increment" and store it, atomically.
Returns the value of this after incrementing.
Has acquire and release semantics.
|
inline |
Atomic compare and swap.
If this value equals "expected", sets this to "newValue". Always returns the original of this.
Has acquire and release semantics.
|
inline |
Atomic compare and swap.
If this value equals "expected", sets this to "newValue". Always returns the original of this.
Has acquire and release semantics.
|
inline |
Get the current value of this, add "increment" and store it, atomically.
Returns the value of this before incrementing.
Has acquire and release semantics.
|
inline |
Get the current value of this, add "increment" and store it, atomically.
Returns the value of this before incrementing.
Has acquire and release semantics.
|
inline |
Get the current value of this, subtract "decrement" and store it, atomically.
Returns the value of this before decrementing.
Has acquire and release semantics.
|
inline |
Get the current value of this, subtract "decrement" and store it, atomically.
Returns the value of this before decrementing.
Has acquire and release semantics.
|
inline |
Gets the current value of this AtomicWord.
Has acquire and release semantics.
|
inline |
Gets the current value of this AtomicWord.
Has acquire and release semantics.
|
inline |
Gets the current value of this AtomicWord.
Has relaxed semantics.
|
inline |
Gets the current value of this AtomicWord.
Has relaxed semantics.
|
inline |
Sets the value of this AtomicWord to "newValue".
Has acquire and release semantics.
|
inline |
Sets the value of this AtomicWord to "newValue".
Has acquire and release semantics.
|
inline |
Get the current value of this, subtract "decrement" and store it, atomically.
Returns the value of this after decrementing.
Has acquire and release semantics.
|
inline |
Get the current value of this, subtract "decrement" and store it, atomically.
Returns the value of this after decrementing.
Has acquire and release semantics.
|
inline |
Atomically swaps the current value of this with "newValue".
Returns the old value.
Has acquire and release semantics.
|
inline |
Atomically swaps the current value of this with "newValue".
Returns the old value.
Has acquire and release semantics.