std::atomic and Memory Orders
Use std::atomic with the right memory ordering for correctness and speed.
Beyond Mutexes
Locks serialize access — they are simple and correct, but they limit throughput. std::atomic provides lock-free building blocks for high-throughput concurrent code.
std::atomic Basics
An std::atomic<T> wraps a value and supports atomic read-modify-write operations.
#include <atomic>
std::atomic<int> counter{0};
counter.fetch_add(1); // atomic increment
int v = counter.load();
counter.store(0);All lessons in this course
- std::atomic and Memory Orders
- Compare-and-Swap CAS Patterns
- Lock-Free Queue Implementation
- Hazard Pointers and the ABA Problem