0Pricing
C++ Academy · Lesson

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

  1. std::atomic and Memory Orders
  2. Compare-and-Swap CAS Patterns
  3. Lock-Free Queue Implementation
  4. Hazard Pointers and the ABA Problem
← Back to C++ Academy