##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Atomic operations library

From cppreference.com
< cpp

The 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 objects are free of data races.

Defined in header `<atomic>`
##### Atomic types
atomic (C++11) | atomic class template and specializations for bool, integral, and pointer types (class template) [edit]
##### Operations on atomic types
atomic_is_lock_free (C++11) | checks if the atomic type's operations are lock-free (function template) [edit]
atomic_store atomic_store_explicit (C++11)(C++11) | atomically replaces the value of the atomic object with a non-atomic argument (function template) [edit]
atomic_load atomic_load_explicit (C++11)(C++11) | atomically obtains the value stored in an atomic object (function template) [edit]
atomic_exchange atomic_exchange_explicit (C++11)(C++11) | atomically replaces the value of the atomic object with non-atomic argument and returns the old value of the atomic (function template) [edit]
atomic_compare_exchange_weak atomic_compare_exchange_weak_explicit atomic_compare_exchange_strong atomic_compare_exchange_strong_explicit (C++11)(C++11)(C++11)(C++11) | atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not (function template) [edit]
atomic_fetch_add atomic_fetch_add_explicit (C++11)(C++11) | adds a non-atomic value to an atomic object and obtains the previous value of the atomic (function template) [edit]
atomic_fetch_sub atomic_fetch_sub_explicit (C++11)(C++11) | subtracts a non-atomic value from an atomic object and obtains the previous value of the atomic (function template) [edit]
atomic_fetch_and atomic_fetch_and_explicit (C++11)(C++11) | replaces the atomic object with the result of logical AND with a non-atomic argument and obtains the previous value of the atomic (function template) [edit]
atomic_fetch_or atomic_fetch_or_explicit (C++11)(C++11) | replaces the atomic object with the result of logical OR with a non-atomic argument and obtains the previous value of the atomic (function template) [edit]
atomic_fetch_xor atomic_fetch_xor_explicit (C++11)(C++11) | replaces the atomic object with the result of logical XOR with a non-atomic argument and obtains the previous value of the atomic (function template) [edit]
##### Flag type and operations
atomic_flag (C++11) | the lock-free boolean atomic type (class) [edit]
atomic_flag_test_and_set atomic_flag_test_and_set_explicit (C++11)(C++11) | atomically sets the flag to true and returns its previous value (function) [edit]
atomic_flag_clear atomic_flag_clear_explicit (C++11)(C++11) | atomically sets the value of the flag to false (function) [edit]
##### Initialization
atomic_init (C++11) | non-atomic initialization of a default-constructed atomic object (function template) [edit]
ATOMIC_VAR_INIT (C++11) | constant initialization of an atomic variable of static storage duration (function macro) [edit]
ATOMIC_FLAG_INIT (C++11) | initializes an std::atomic_flag to false (macro constant) [edit]
##### Memory synchronization ordering
memory_order (C++11) | defines memory ordering constraints for the given atomic operation (typedef) [edit]
kill_dependency (C++11) | removes the specified object from the std::memory_order_consume dependency tree (function template) [edit]
atomic_thread_fence (C++11) | generic memory order-dependent fence synchronization primitive (function) [edit]
atomic_signal_fence (C++11) | fence between a thread and a signal handler executed in the same thread (function) [edit]

### [edit] See also

C documentation for Atomic operations library

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/atomic&oldid=83389"