All Atomics and Memory Ordering
All Atomics and Memory Ordering
A compact scan page for standard atomic types, operations, fences, and memory-order vocabulary.
All Atomics and Memory Ordering
A compact scan page for standard atomic types, operations, fences, and memory-order vocabulary.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
std::atomic<T>std::atomic_flagstd::atomic_ref<T>loadstoreexchangecompare_exchange_weakcompare_exchange_strongfetch_add, fetch_subfetch_and, fetch_or, fetch_xorwait, notify_one, notify_allstd::atomic_thread_fencestd::atomic_signal_fenceis_lock_freeis_always_lock_freestd::memory_ordermemory_order_relaxedmemory_order_consumememory_order_acquirememory_order_releasememory_order_acq_relmemory_order_seq_cstseq_cst until you can justify weaker orders precisely.#include <atomic>
#include <thread>
int main() {
std::atomic<bool> ready{false};
int value = 0;
std::jthread producer([&] {
value = 42;
ready.store(true, std::memory_order_release);
});
while (!ready.load(std::memory_order_acquire)) {
}
return value == 42 ? 0 : 1;
}