C++ Library - <atomic>



Introduction

These are types that encapsulate a value whose access is guaranteed to not cause data races and can be used to synchronize memory accesses among different threads and he atomic library provides components for fine-grained atomic operations allowing for lockless concurrent programming. Each atomic operation is indivisible with regards to any other atomic operation that involves the same object.

Atomic type

Sr.No. Member types & Definition
1 atomic

Atomic class template and specializations for bool, integral, and pointer types

C-style atomic types

The following are atomic types and also defined in this header.

contained type atomic type description
bool atomic_bool
char atomic_char

atomics for fundamental integral types.

These are either typedefs of the corresponding full specialization of the atomic class template or a base class of such specialization.

signed char atomic_schar
unsigned char atomic_uchar
short atomic_short
unsigned short atomic_ushort
int atomic_int
unsigned int atomic_uint
long atomic_long
unsigned long atomic_ulong
long long atomic_llong
unsigned long long atomic_ullong
wchar_t atomic_wchar_t
char16_t atomic_char16_t
char32_t atomic_char32_t
intmax_t atomic_intmax_t

atomics for width-based integrals (those defined in <cinttypes>).

Each of these is either an alias of one of the above atomics for fundamental integral types or of a full specialization of the atomic class template with an extended integral type.

Where N is one in 8, 16, 32, 64, or any other type width supported by the library.

uintmax_t atomic_uintmax_t
int_leastN_t atomic_int_leastN_t
uint_leastN_t atomic_uint_leastN_t
int_fastN_t atomic_int_fastN_t
uint_fastN_t atomic_uint_fastN_t
intptr_t atomic_intptr_t
uintptr_t atomic_uintptr_t
size_t atomic_size_t
ptrdiff_t atomic_ptrdiff_t

Operations on atomic types

Flag type and operations