MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
mongo::AtomicWord< _WordType > Class Template Reference

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.
 
WordType loadRelaxed () const
 Gets the current value of this AtomicWord.
 
void store (WordType newValue)
 Sets the value of this AtomicWord to "newValue".
 
WordType swap (WordType newValue)
 Atomically swaps the current value of this with "newValue".
 
WordType compareAndSwap (WordType expected, WordType newValue)
 Atomic compare and swap.
 
WordType fetchAndAdd (WordType increment)
 Get the current value of this, add "increment" and store it, atomically.
 
WordType fetchAndSubtract (WordType decrement)
 Get the current value of this, subtract "decrement" and store it, atomically.
 
WordType addAndFetch (WordType increment)
 Get the current value of this, add "increment" and store it, atomically.
 
WordType subtractAndFetch (WordType decrement)
 Get the current value of this, subtract "decrement" and store it, atomically.
 
 AtomicWord (WordType value=WordType(0))
 Construct a new word with the given initial value.
 
WordType load () const
 Gets the current value of this AtomicWord.
 
WordType loadRelaxed () const
 Gets the current value of this AtomicWord.
 
void store (WordType newValue)
 Sets the value of this AtomicWord to "newValue".
 
WordType swap (WordType newValue)
 Atomically swaps the current value of this with "newValue".
 
WordType compareAndSwap (WordType expected, WordType newValue)
 Atomic compare and swap.
 
WordType fetchAndAdd (WordType increment)
 Get the current value of this, add "increment" and store it, atomically.
 
WordType fetchAndSubtract (WordType decrement)
 Get the current value of this, subtract "decrement" and store it, atomically.
 
WordType addAndFetch (WordType increment)
 Get the current value of this, add "increment" and store it, atomically.
 
WordType subtractAndFetch (WordType decrement)
 Get the current value of this, subtract "decrement" and store it, atomically.
 

Detailed Description

template<typename _WordType>
class mongo::AtomicWord< _WordType >

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.

Member Function Documentation

◆ addAndFetch() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::addAndFetch ( WordType  increment)
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.

◆ addAndFetch() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::addAndFetch ( WordType  increment)
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.

◆ compareAndSwap() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::compareAndSwap ( WordType  expected,
WordType  newValue 
)
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.

◆ compareAndSwap() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::compareAndSwap ( WordType  expected,
WordType  newValue 
)
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.

◆ fetchAndAdd() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::fetchAndAdd ( WordType  increment)
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.

◆ fetchAndAdd() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::fetchAndAdd ( WordType  increment)
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.

◆ fetchAndSubtract() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::fetchAndSubtract ( WordType  decrement)
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.

◆ fetchAndSubtract() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::fetchAndSubtract ( WordType  decrement)
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.

◆ load() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::load ( ) const
inline

Gets the current value of this AtomicWord.

Has acquire and release semantics.

◆ load() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::load ( ) const
inline

Gets the current value of this AtomicWord.

Has acquire and release semantics.

◆ loadRelaxed() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::loadRelaxed ( ) const
inline

Gets the current value of this AtomicWord.

Has relaxed semantics.

◆ loadRelaxed() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::loadRelaxed ( ) const
inline

Gets the current value of this AtomicWord.

Has relaxed semantics.

◆ store() [1/2]

template<typename _WordType >
void mongo::AtomicWord< _WordType >::store ( WordType  newValue)
inline

Sets the value of this AtomicWord to "newValue".

Has acquire and release semantics.

◆ store() [2/2]

template<typename _WordType >
void mongo::AtomicWord< _WordType >::store ( WordType  newValue)
inline

Sets the value of this AtomicWord to "newValue".

Has acquire and release semantics.

◆ subtractAndFetch() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::subtractAndFetch ( WordType  decrement)
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.

◆ subtractAndFetch() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::subtractAndFetch ( WordType  decrement)
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.

◆ swap() [1/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::swap ( WordType  newValue)
inline

Atomically swaps the current value of this with "newValue".

Returns the old value.

Has acquire and release semantics.

◆ swap() [2/2]

template<typename _WordType >
WordType mongo::AtomicWord< _WordType >::swap ( WordType  newValue)
inline

Atomically swaps the current value of this with "newValue".

Returns the old value.

Has acquire and release semantics.


The documentation for this class was generated from the following files: