Skip to content
C++

Concurrency

17 concurrency pages — threads, synchronization primitives, atomics, lock-free, and C++20 additions.

Condition Variables

std::condition_variable — atomic wait/notify, spurious wakeup handling, timed waits, condition_variable_any, and C++20 stop_token integration.

C++11
Lock-Free Programming

C++ lock-free programming — compare_exchange, memory orders, Treiber stack, ABA problem, safe reclamation, and when to prefer mutexes.

C++11
Read-Copy Update (RCU)

Lock-free reader synchronization for read-heavy workloads — readers never block; writers retire old data after a guaranteed grace period.

C++26
Semaphore, Latch, and Barrier (C++20)

C++20 counting_semaphore, binary_semaphore, latch, and barrier — efficient thread synchronization primitives with defined happens-before semantics.

C++20
std::async, future, promise, packaged_task

"C++11 async primitives: std::async for task-based concurrency, future/promise as a one-shot cross-thread value channel, packaged_task for callable wrapping."

C++11
std::atomic

std::atomic<T> provides lock-free atomic operations with configurable memory ordering — covers memory orders, CAS loops, atomic_flag, atomic_ref, wait/notify, and fences.

C++11
std::atomic_ref

Apply atomic operations to existing non-atomic objects with std::atomic_ref (C++20): syntax, alignment rules, specializations, and pitfalls.

C++20
std::call_once and std::once_flag

Thread-safe one-time initialization in C++11 with std::call_once and std::once_flag, including exception semantics, lazy init patterns, and comparison with function-local statics.

C++11
std::execution — Senders & Receivers (C++26)

P2300 Senders/Receivers: structured, composable async that decouples work from execution context — portable parallelism across thread pools, GPU queues, and event loops without callbacks.

C++26
std::jthread and Cooperative Cancellation (C++20)

"C++20 std::jthread: auto-joining thread with cooperative cancellation via stop_token, stop_source, and stop_callback."

C++20
std::memory_order

Controls how memory accesses around atomic operations are ordered across threads; the backbone of C++'s lock-free concurrency model.

C++11
std::mutex, lock_guard, unique_lock, scoped_lock, condition_variable

C++ mutual exclusion primitives — mutex variants, RAII lock guards, condition variables, and correct patterns for thread-safe code.

C++11
std::packaged_task

A move-only callable wrapper that stores its result or exception in a shared state accessible via std::future.

C++11
std::promise

Write-end of a one-shot, thread-safe channel; pairs with std::future to pass a value or exception across threads.

C++11
std::shared_mutex

C++17 reader-writer mutex allowing multiple concurrent shared (read) locks alongside a single exclusive (write) lock, eliminating false serialization of reads.

C++17
std::thread, mutex, atomic, condition_variable

C++11 portable threading model — thread creation, mutual exclusion, lock-free atomics, and condition-variable signaling for safe concurrent programs.

C++11
thread_local Storage Duration

C++ thread_local — per-thread variables, initialization semantics, destruction order, async pitfalls, and performance characteristics.

C++11