Chapters

The whole book, in order.

Ten parts, read in order the first time through. Each chapter also stands on its own for a reader jumping in to solve one problem. Pick a part, or start at the top.

Part 0 Orientation

How to read this book, who it's for, the KVM lab used for parallelism work, and the C++20/23/26 standards tabs that run through every chapter.

  1. PrerequisitesThe reference platform (Fedora), the C++ toolchain and container engine to install, the optional KVM lab for the parallelism chapters, and the preferred editor.

Part 1 Foundations

Concurrency versus parallelism, the machine underneath — cores, SMT, cache, NUMA — time and deadlines, and threads in modern C++.

  1. Concurrency vs ParallelismThe two independent axes of concurrency and parallelism, the four execution models that result, and how to measure them precisely.
  2. The Machine UnderneathThe hardware concurrency sits on top of: cores, simultaneous multithreading, cache coherence, NUMA topology, and the scheduler's context-switch cost.
  3. Time, Timers, and DeadlinesThe clock taxonomy a concurrent service actually needs, monotonic time, timeouts, and propagating a deadline across a call chain.
  4. Threads in Modern C++std::thread and std::jthread, cooperative cancellation with stop_token, and the lifetime and ownership rules that govern joining versus detaching.

Part 2 Shared State and Synchronization

The futex underneath a lock, mutual exclusion, coordination primitives, the memory model, and lock-free structures.

  1. Shared State and the FutexWhat a mutex actually is underneath the standard library: the futex syscall, and the cost difference between an uncontended and a contended lock.
  2. Mutual Exclusion and LockingThe mutex family, the RAII lock wrapper types, and the lock-ordering discipline that avoids deadlock.
  3. Coordination Primitivescondition_variable, C++20's latch and barrier, and counting_semaphore, and how to choose among them.
  4. Atomics and the Memory Modelstd::atomic, the C++ memory model's ordering options, fences, and the real performance cost of stricter ordering.
  5. Lock-Free Data StructuresSingle- and multi-producer/consumer ring buffers, the ABA problem, hazard pointers, RCU, and C++26's standardized reclamation support.

Part 3 Tasks, Futures, and Asynchrony

Futures and packaged tasks, coroutines, async runtimes and event loops, and stackful fibers.

  1. Futures, Promises, and Packaged Tasksstd::async and its launch policies, the future/promise pair, packaged_task, shared_future, and how exceptions cross the async boundary.
  2. Coroutines in DepthC++20 coroutine machinery, promise_type and awaitables, the heap allocation that the compiler may elide, and a look ahead to C++26 senders and receivers.
  3. Async Runtimes and Event LoopsThe epoll event loop underneath async I/O, Boost.Asio's strand and work-guard, and the question of which thread actually runs a given handler.
  4. Fibers and Stackful CoroutinesStackful fibers versus stackless coroutines, what the fiber's own stack buys and costs, the guard page, and choosing a scheduler.

Part 4 Parallelism and Throughput

Parallel algorithms and execution policies, thread pools, NUMA and affinity, and SIMD data parallelism.

  1. Parallel Algorithms and Execution PoliciesThe standard execution policies, the parallel STL algorithms built on them, C++26 additions, and when parallel execution actually pays off.
  2. Thread Pools and Work SchedulingSizing a thread pool correctly, work-stealing task queues, bounded queues and back-pressure, and the cgroup-aware sizing a pool needs to behave inside a container.
  3. NUMA, Affinity, and Data LocalityCPU pinning and affinity, NUMA-aware allocation, the latency gap between local and remote memory, and how cpuset constraints interact with it.
  4. SIMD and Data ParallelismVectorization fundamentals, what defeats autovectorization, the upcoming C++26 std::simd, and the data layout choices that make vectorization possible in the first place.

Part 5 Low Latency and High Throughput

Benchmarking without deception, the fast path, mechanical sympathy, and lock-free messaging.

  1. Benchmarking Without DeceptionWarmup and the cold-call bias, coordinated omission and why it hides the tail, percentiles versus the mean, wall-clock vs CPU time, and the repeatable harness this book's other chapters cite for their own benchmark claims.
  2. The Low-Latency Fast PathThree concrete moves that shrink tail latency: core pinning, buffer reuse, and zero allocation, the busy-poll versus block decision, keeping syscalls and branches off the hot path, and where kernel bypass fits.
  3. Mechanical SympathyFalse sharing and the cache line, alignas and hardware_destructive_interference_size, struct layout, per-thread counters versus a single hot atomic, and the cache-line discipline that keeps hot data from fighting over a line.
  4. Lock-Free Messaging and the DisruptorRing buffers revisited as a messaging substrate, the Disruptor pattern, batching and back-pressure, and the single-writer principle that makes it all safe.

Part 6 Communications and Concurrency

Communication models, the actor model and channels, concurrent REST, and concurrent gRPC.

  1. Communication ModelsShared memory versus message passing, the concrete IPC mechanisms available on Linux, D-Bus as a higher-level bus, and a decision guide for picking among them.
  2. The Actor Model and ChannelsActors and mailboxes, CSP-style channels, confinement as a design discipline, and how to write no-shared-state message passing in C++.
  3. Concurrent REST EndpointsThread-per-request versus async handlers, a minimal Boost.Asio/Beast server, and the back-pressure and overload-shedding strategies that keep it alive under load.
  4. Concurrent gRPC ServicesThe async gRPC completion-queue API, streaming RPCs, and the thread-pool sizing decisions that determine how many requests a gRPC server can serve concurrently.

Part 7 Correctness, Errors, and Debugging

Error versus exception handling, debugging real races and deadlocks, sanitizers, and observing concurrency in production.

  1. Error Handling vs Exception HandlingError codes versus exceptions, std::expected as a middle ground, propagating errors across thread, future, and coroutine boundaries, and exception safety under concurrency.
  2. Debugging Real Races and DeadlocksReproducing an actual data race and an actual deadlock, driving gdb against a multithreaded program, and reading a ThreadSanitizer report line by line.
  3. Sanitizers and Dynamic AnalysisThreadSanitizer and AddressSanitizer, Valgrind's Helgrind and DRD, what each tool catches and misses, and wiring them into CI.
  4. Observing ConcurrencyInstrumenting a concurrent C++ service with OpenTelemetry, propagating trace context across thread-pool, future, and coroutine boundaries, and the saturation and contention metrics that reveal a struggling pool before it becomes an incident.

Part 8 Practice: Design, Containers, and a Full Example

Coding practices, design and architecture patterns, concurrency in containers, and an end-to-end project that ties the book together.

  1. Coding Practices for ConcurrencyImmutability, RAII locking, const-correctness as a concurrency tool, minimizing and confining shared state, and the naming and documentation conventions that make a threading contract legible without reading the implementation.
  2. Design and Architecture PatternsPipeline and SEDA architectures, sharding and the single-writer pattern, the reactor and proactor behind half-sync/half-async, fan-out/fan-in, and a decision framework for matching a concurrency architecture to a latency or throughput goal.
  3. Concurrency in Containerscgroup CPU quota versus cpuset, why hardware_concurrency() lies inside a container, sizing pools to the real quota, and pinning under an orchestrator.
  4. Full Example: Ingest, Match, PublishAn end-to-end low-latency pipeline (ingest, match, publish) that composes the concurrency, lock-free messaging, and observability patterns from earlier chapters, measured under load.

Part 9 Appendix

Build and toolchain reference: clang, gdb, CMake presets, and Conan lockfiles, plus the Lua verify.lua harness used to confirm every example actually does what it claims.

  1. Appendix: Build and ToolchainThe project's build and verification toolchain: clang and gdb, CMake presets, Conan lockfiles, the Lua verify.lua harness, and GCC/clang parity checks.