atomic Structure
Describes an object that performs atomic operations on a stored value of type Ty.
template <class Ty>
struct atomic;
Members
Public Constructors
Name |
Description |
---|---|
Constructs an atomic object. |
Public Operators
Name |
Description |
---|---|
Reads and returns the stored value. (atomic::load Method) |
|
Uses a specified value to replace the stored value. (atomic::store Method) |
|
Increments the stored value. Used only by integral and pointer specializations. |
|
Adds a specified value to the stored value. Used only by integral and pointer specializations. |
|
Decrements the stored value. Used only by integral and pointer specializations. |
|
Subtracts a specified value from the stored value. Used only by integral and pointer specializations. |
|
Performs a bitwise and on a specified value and the stored value. Used only by integral specializations. |
|
Performs a bitwise or on a specified value and the stored value. Used only by integral specializations. |
|
Performs a bitwise exclusive or on a specified value and the stored value. Used only by integral specializations. |
Public Methods
Name |
Description |
---|---|
Performs an atomic_compare_and_exchange operation on this and returns the result. |
|
Performs a weak_atomic_compare_and_exchange operation on this and returns the result. |
|
Adds a specified value to the stored value. |
|
Performs a bitwise and on a specified value and the stored value. |
|
Performs a bitwise or on a specified value and the stored value. |
|
Subtracts a specified value from the stored value. |
|
Performs a bitwise exclusive or on a specified value and the stored value. |
|
Specifies whether atomic operations on this are lock free. An atomic type is lock free if no atomic operations on that type use locks. |
|
Reads and returns the stored value. |
|
Uses a specified value to replace the stored value. |
Remarks
The type Ty must be trivially copyable. That is, using memcpy to copy its bytes must produce a valid Ty object that compares equal to the original object. The compare_exchange_weak and compare_exchange_strong member functions use memcmp to determine whether two Ty values are equal. These functions will not use a Ty-defined operator==. The member functions of atomic use memcpy to copy values of type Ty.
A partial specialization, atomic<Ty *>, exists for all pointer types. The specialization enables the addition of an offset to the managed pointer value or the subtraction of an offset from it. The arithmetic operations take an argument of type ptrdiff_t and adjust that argument according to the size of Ty to be consistent with ordinary address arithmetic.
A specialization exists for every integral type except bool. Each specialization provides a rich set of methods for atomic arithmetic and logical operations.
atomic<char> |
atomic<signed char> |
atomic<unsigned char> |
atomic<char16_t> |
atomic<char32_t> |
atomic<wchar_t> |
atomic<short> |
atomic<unsigned short> |
atomic<int> |
atomic<unsigned int> |
atomic<long> |
atomic<unsigned long> |
atomic<long long> |
atomic<unsigned long long> |
Integral specializations are derived from corresponding **atomic_**integral types. For example, atomic<unsigned int> is derived from atomic_uint.
Requirements
Header: atomic
Namespace: std