The C++ Standard Library
- C++ Library - <valarray>
- C++ Library - <utility>
- C++ Library - <typeinfo>
- C++ Library - <tuple>
- C++ Library - <thread>
- C++ Library - <string>
- C++ Library - <stdexcept>
- C++ Library - <regex>
- C++ Library - <numeric>
- C++ Library - <new>
- C++ Library - <memory>
- C++ Library - <locale>
- C++ Library - <limits>
- C++ Library - <functional>
- C++ Library - <exception>
- C++ Library - <complex>
- C++ Library - <atomic>
- C++ Library - <streambuf>
- C++ Library - <sstream>
- C++ Library - <ostream>
- C++ Library - <istream>
- C++ Library - <iostream>
- C++ Library - <iosfwd>
- C++ Library - <ios>
- C++ Library - <iomanip>
- C++ Library - <fstream>
- C++ Library - Home
The C++ STL Library
- C++ Library - <iterator>
- C++ Library - <algorithm>
- C++ Library - <vector>
- C++ Library - <unordered_set>
- C++ Library - <unordered_map>
- C++ Library - <stack>
- C++ Library - <set>
- C++ Library - <queue>
- C++ Library - <map>
- C++ Library - <list>
- C++ Library - <forward_list>
- C++ Library - <deque>
- C++ Library - <bitset>
- C++ Library - <array>
C++ Programming Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
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 pbrary provides components for fine-grained atomic operations allowing for lockless concurrent programming. Each atomic operation is inspanisible with regards to any other atomic operation that involves the same object.
Atomic type
Sr.No. | Member types & Definition |
---|---|
1 |
Atomic class template and speciapzations 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 speciapzation of the atomic class template or a base class of such speciapzation. |
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 apas of one of the above atomics for fundamental integral types or of a full speciapzation 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 pbrary. |
uintmax_t | atomic_uintmax_t | |
int_least N_t |
atomic_int_least N_t |
|
uint_least N_t |
atomic_uint_least N_t |
|
int_fast N_t |
atomic_int_fast N_t |
|
uint_fast N_t |
atomic_uint_fast N_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
Sr.No. | Operations & Definition |
---|---|
1 |
It is used to checks if the atomic type s operations are lock-free |
2 |
It automically replaces the value of the atomic object with a non-atomic argument |
3 |
It atomically obtains the value stored in an atomic object |
4 |
It atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic |
5 |
It atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not |
6 |
It adds a non-atomic value to an atomic object and obtains the previous value of the atomic |
7 |
It subtracts a non-atomic value from an atomic object and obtains the previous value of the atomic |
8 |
It replaces the atomic object with the result of logical AND with a non-atomic argument and obtains the previous value of the atomic |
9 |
It replaces the atomic object with the result of logical OR with a non-atomic argument and obtains the previous value of the atomic |
10 |
It replaces the atomic object with the result of logical XOR with a non-atomic argument and obtains the previous value of the atomic |
Flag type and operations
Sr.No. | Flag type & Definition |
---|---|
1 |
The lock-free boolean atomic type |
2 |
It atomically sets the flag to true and returns its previous value |
3 |
It atomically sets the value of the flag to false |