What you will learn in C++ Concurrency in Action, Second Edition
Chapter by chapter
Chapter 1: Chapter 1. Hello, world of concurrency in C++!
The chapter introduction explains why C++11’s standardized multithreading support mattered and previews the chapter’s path from basic concepts to a simple concurrent program.
What you learn in chapter 1 →Chapter 2: Chapter 2. Managing threads
The chapter introduces std::thread as the main way to manage threads and previews the thread-management tasks it will cover.
What you learn in chapter 2 →Chapter 3: Chapter 3. Sharing data between threads
The chapter introduces the benefits and risks of sharing data between threads and previews ways to protect it.
What you learn in chapter 3 →Chapter 4: Chapter 4. Synchronizing concurrent operations
The chapter introduces waiting for other threads’ actions and surveys the C++ facilities used to synchronize them.
What you learn in chapter 4 →Chapter 5: Chapter 5. The C++ memory model and operations on atomic types
This introduction explains why C++ needs a multithreading-aware memory model, when programmers need its details, and how the chapter will approach atomic synchronization.
What you learn in chapter 5 →Chapter 6: Chapter 6. Designing lock-based concurrent data structures
The chapter introduces why data structures need deliberate design for concurrent access and previews lock-based examples before a later chapter turns to lock-free designs.
What you learn in chapter 6 →Chapter 7: Chapter 7. Designing lock-free concurrent data structures
The introduction motivates lock-free data structures, identifies atomic memory ordering as their foundation, and previews the chapter’s definitions, examples, memory-management techniques, and guidelines.
What you learn in chapter 7 →Chapter 8: Chapter 8. Designing concurrent code
The introduction shifts from building thread-safe data structures to designing useful concurrent code, outlining the decisions and tradeoffs the chapter will examine.
What you learn in chapter 8 →Chapter 9: Chapter 9. Advanced thread management
The introduction motivates automatic management of threads and tasks, explains why threads sometimes need to stop early, and previews the chapter’s two topics.
What you learn in chapter 9 →Chapter 10: Chapter 10. Parallel algorithms
The introduction connects earlier work on concurrent code and thread pools to the chapter’s focus on C++17 standard parallel algorithms.
What you learn in chapter 10 →Chapter 11: Chapter 11. Testing and debugging multithreaded applications
The chapter introduces the difficulty of testing and debugging concurrent code and outlines an issues-first approach to finding and removing bugs.
What you learn in chapter 11 →Concepts explained in this book
- synchronizes-with relationA C++ memory-model relation between operations that establishes inter-thread ordering and visibility.
- memory orderingThe constraints governing how memory operations are ordered and observed across threads in the C++ memory model.
- race conditionA race condition is a program condition in which behavior depends on the timing or ordering of operations performed by concurrent threads.
- futureAn object representing a value that may become available later, often as the result of asynchronous work.
- deadlockDeadlock is a state in which two or more threads are indefinitely blocked, each waiting for a resource or event that another blocked thread must provide.
- modification orderA per-object order of all writes to that object, including its initialization, on which all threads in a given execution must agree.
- acquire-release semanticsAcquire-release ordering provides synchronization when an acquire operation reads a value written by a release operation, without imposing a single global order.
- sequential consistencySequentially consistent ordering requires atomic operations using that ordering to fit one total order consistent with each thread's program order.
- thread-safe queueA queue designed to support safe operations by multiple threads.
- thread-safe stackThe thread-safe stack is the example application's stack type that coordinates access among threads and throws when empty.
- concurrencyConcurrency is the structuring and execution of multiple tasks whose progress overlaps, whether or not they run at the exact same time.
- fine-grained lockingFine-grained locking protects smaller portions of shared data with separate locks rather than one broad lock.
- lock-free data structureA data structure whose operations provide lock-free progress without acquiring locks.
- memory reclamationMemory reclamation is the process of safely releasing memory occupied by objects that are no longer in use.
- std::async`std::async` is a C++ standard library function template that launches a function asynchronously or defers its execution and returns a future for its result.
- acquire semanticsAn acquire operation is an atomic operation whose ordering can synchronize with a release operation on the same memory location.
- hazard pointerA memory-reclamation technique in which threads publish pointers to objects they may access so those objects are not reclaimed prematurely.
- locking granularityLock granularity is the amount of data protected by a single lock.
- lockless techniqueA progress guarantee under which, when threads continue taking steps, at least one operation completes despite contention.
- happens-before relationA C++ memory-model ordering relation between evaluations that establishes when one precedes another, including across threads.
- std::packaged_task`std::packaged_task` is a C++ standard library class template that wraps a callable and stores its result in a shared state accessible through a future.
- multithreadingA programming technique in which a program uses multiple threads of execution within a process.
- false sharingFalse sharing is a performance problem in which distinct data items accessed by different threads occupy the same cache line, causing unnecessary cache-line transfers.
- exception safetyException safety is the property of a program or operation maintaining defined behavior and resource integrity when exceptions occur.
- barrierA synchronization primitive that makes participating threads wait until all have reached a synchronization point.
- helpingA lock-free algorithm technique in which a thread completes work initiated by another thread so the system can make progress if that thread stalls.
- external reference countA count associated with a pointer accessible to multiple threads that tracks external references to a node.
- internal reference countA count that tracks references to a node held by threads that have already accessed it through an external pointer.
- threadA unit of execution within a process that can run independently of other threads.
- forward-propagation algorithmA parallel prefix-sum technique that computes sums in chunks and propagates each chunk’s accumulated total to subsequent chunks.
- incremental pairwise algorithmA parallel prefix-sum technique that repeatedly combines values with partial sums from increasingly larger distances.
- continuationA continuation is a function scheduled to run automatically after an asynchronous computation reaches a specified completion point.
- lock hierarchyA convention in which threads acquire multiple locks in a consistent order to prevent circular waiting.
- separation of concernsSeparation of concerns is a software design principle that organizes a system so distinct concerns are handled independently.
- std::shared_futureA C++ Concurrency TS class template representing an asynchronous result accessible by multiple consumers.
- condition variableA condition variable is a synchronization primitive that lets threads wait for a condition and be notified when it may have changed.
- task-based work divisionAssignment of portions of a computation to different threads for execution.
- spinlockA mutex implementation in which a waiting thread repeatedly attempts to acquire the lock rather than blocking.
- access patternA data access pattern is the way a computation reads or writes locations in memory over time.
- std::threadA C++ standard library class that represents and manages a thread of execution.
- compare-and-exchange operationAn operation that atomically compares an object's value with an expected value and conditionally replaces it with a desired value.
- thread poolA thread pool is a managed collection of reusable threads that execute submitted tasks.
- release operationA release operation is an atomic operation whose ordering can synchronize with an acquire operation on the same memory location.
- data raceA data race occurs when concurrent operations access the same memory location, at least one operation modifies it, and the operations are not properly synchronized.
- generic atomic interfaceA C++ standard library class template whose specializations provide atomic operations on values of supported types.
- std::promise`std::promise` is a C++ standard library class template that stores a value or exception in a shared state for an associated future to retrieve.
- parallel algorithmAn algorithm that can distribute its work across multiple execution agents.
- execution policyA C++ standard-library policy that specifies how an algorithm may execute, including whether it may run in parallel.
- hardware concurrencyHardware concurrency is the degree of parallel execution supported by the available hardware.
- lambdaA lambda expression is a C++ expression that defines an unnamed callable, optionally capturing variables from its surrounding scope.
- dangling pointerA dangling pointer is a pointer that refers to an object whose lifetime has ended or whose storage is no longer valid.
- undefined behaviorUndefined behavior is program behavior for which the C++ language standard imposes no requirements.
- mutexA synchronization primitive used to coordinate exclusive access to a shared resource.
- read-modify-write operationA read-modify-write operation atomically reads a value, modifies it, and writes the result as one operation.
- atomic_flagA C++ standard library atomic Boolean flag with test-and-set and clear operations.
- atomic typeAn atomic type is a type whose operations provide atomic access to an object and support synchronization between threads.
- functional, stateless philosophyFunctional programming is a programming style that emphasizes computing results from inputs while avoiding mutable external state.
- get`get()` is a future operation that retrieves the result represented by the future, waiting for it if necessary and rethrowing any stored exception.
- scalabilityScalability is the ability of a system or algorithm to increase its capacity as available resources increase.
- ownership transferOwnership transfer is the reassignment of responsibility for managing a resource, such as a lock, from one entity to another.
- release sequenceA release sequence is a sequence of operations on an atomic object beginning with a release operation and continuing through qualifying read-modify-write operations that read the preceding value.
- std::thread::detach()`std::thread::detach()` separates a thread of execution from its `std::thread` object, allowing it to continue independently.
- sequenced-before relationA C++ ordering relation between evaluations within a single thread.
- pipelineA pipeline is a processing pattern in which work passes through a sequence of stages.
- cache ping-pongCache ping-pong is performance-degrading cache-coherence traffic caused by multiple threads repeatedly accessing the same shared data.
- message passingMessage passing is a communication technique in which concurrent components exchange information by sending and receiving messages.
- reference countingReference counting is a memory-management technique that tracks how many references point to an object and reclaims it when the count reaches zero.
- lock-free stackThe lock-free stack is the example data structure whose push and pop operations use atomic pointer updates and manual reference counting.
- then()`then()` is a C++ Concurrency TS future operation that attaches a continuation to run after the future becomes ready.
- std::memory_order_releaseA C++ memory-order value that gives an atomic store release semantics, making preceding operations visible to a thread that performs a matching acquire operation.
- oversubscriptionA condition in which more threads are run than the hardware can support concurrently.
- actor modelThe actor model is a concurrency model in which independent actors communicate by sending messages and do not share state directly.
- finite-state machineA finite state machine is a computational model with a finite set of states and transitions triggered by inputs or events.
- std::atomic<bool>A C++ standard library atomic type that provides atomic operations on a Boolean value.
- std::move`std::move` is a C++ standard library function template that casts an expression to an rvalue reference, enabling move operations.
- std::shared_ptr`std::shared_ptr` is a C++ standard library smart pointer that shares ownership of a dynamically allocated object.
- lock_guardA C++ standard library class template that acquires a lock on construction and releases it on destruction.
- task switchingA scheduling technique in which a processor alternates execution among tasks, running part of each in turn.
- code reviewCode review is the systematic examination of source code to identify defects, improve quality, and check conformance to standards.
- unique_lock`std::unique_lock` is a C++ standard library class template that manages ownership of a mutex lock and supports deferred locking, unlocking, and ownership transfer.
- combination simulation testingCombination simulation testing records concurrent operations and systematically explores permitted combinations of those operations to detect concurrency errors.
- stress testBrute-force testing repeatedly executes software, often under varied or high-load conditions, to expose failures that occur only under particular execution schedules.
- multithreaded testMultithreaded test code coordinates multiple threads so that selected operations execute concurrently and their results can be checked.
- work stealingWork stealing is a scheduling technique in which an idle worker takes tasks from another worker’s queue.
- std::scoped_lockA C++ standard library class template that acquires ownership of one or more lockable objects and releases them on destruction.
- recursionRecursion is a technique in which a function or process calls itself to solve smaller instances of a problem.
- std::memory_order`std::memory_order` is a C++ standard library enumeration whose values specify memory-ordering constraints for atomic operations.
- resource acquisition is initializationResource Acquisition Is Initialization is a C++ programming idiom that binds resource ownership and release to object lifetime.
- std::experimental::atomic_shared_ptr`std::experimental::atomic_shared_ptr` is a C++ Concurrency TS type that provides atomic operations on shared-pointer ownership.
- std::thread::hardware_concurrencyA C++ standard library function that returns a hint about the number of hardware threads available for concurrent execution.
- wait-free progress conditionWait-free describes a progress guarantee in which every thread completes its operation in a bounded number of steps, regardless of other threads’ activity.
- data structureAn organization of data that supports particular operations for storing, accessing, or modifying it.
- is_lock_free()`is_lock_free()` is an atomic member function that reports whether operations on an atomic object are lock-free.
- clockA C++ chrono clock is a class that provides a time source, a time-point type, a tick period, and information about whether it is steady.
- interruptible waitA blocking wait operation that returns control when the waiting thread is interrupted.
- concurrent accessConcurrent access is access to the same data by multiple threads during overlapping periods of execution.
- std::lock`std::lock` is a C++ standard library function template that locks multiple lockable objects together while avoiding deadlock among those objects.
- inter-thread orderingThe inter-thread happens-before relationship orders operations across threads through synchronization and sequencing rules.
- call_once`std::call_once` is a C++ standard library function template that ensures a callable is executed exactly once for a given `std::once_flag`.
- wait-free data structureA data structure whose operations guarantee that every accessing thread completes within a bounded number of steps, regardless of other threads’ behavior.
- atomic operationAn atomic operation is an operation that appears indivisible to other threads under the C++ memory model.
- callableA callable object is an object that can be invoked with function-call syntax.
- object lifetimeAn object's lifetime is the period during which the C++ object exists and may be validly accessed.
- invariantAn invariant is a condition that remains true about a data structure or program state when it is in a valid state.
- absolute timeoutAn absolute timeout is a deadline expressed as a particular point on a clock's timeline, rather than as a relative duration to wait.
- memory barrierA fence is a synchronization operation that constrains the ordering of memory operations without itself accessing the protected object.
- moveMove semantics are C++ language features that allow resources to be transferred from one object to another without copying them.
- double-checked locking patternDouble-checked locking is a synchronization pattern that checks a shared pointer before and after acquiring a lock to avoid locking when initialization is complete.
- std::once_flag`std::once_flag` is a noncopyable C++ standard library type whose instances coordinate one-time execution with `std::call_once`.
- clear()`clear()` is a `std::atomic_flag` member function that sets the flag to the clear state.
- thread-aware memory modelA programming-language memory model that defines how operations on memory behave and become visible across threads.
- serial regionA portion of a program in which one thread performs the computation rather than multiple threads working concurrently.
- memory locationA memory location in C++ is a storage unit consisting of an object of scalar type or a sequence of adjacent bit-fields.
- thread argument passingThread argument passing is the behavior governing how arguments are stored and supplied when starting a thread function.
- serializationSerialization is the restriction of concurrent operations so that they execute in a sequential order rather than simultaneously.
- thread-safe data structureA data structure that permits supported concurrent operations while preserving its invariants.
- std::execution::parThe C++ standard-library execution policy object for parallel execution.
- time_point`std::chrono::time_point` is a C++ standard library class template representing a point in time relative to a clock's epoch.
- concurrent testingTesting software for defects that arise when multiple threads or computations execute concurrently.
- livelockA livelock is a state in which threads repeatedly change or retry operations in response to one another without making useful progress.
- std::experimental::when_anyA C++ Concurrency TS function that returns a future which becomes ready when any supplied future is ready.
- shared_mutexA C++ standard library mutex type that supports either exclusive ownership by one thread or shared ownership by multiple threads.
- spurious wakeupA spurious wakeup is a return from a condition-variable wait without a notification that makes the awaited condition true.
- lock-based data structureA data structure whose concurrent operations use locks to control access to its data.
- steady clockA steady clock is a clock whose measured time never decreases and advances at a steady rate, making it suitable for measuring elapsed time.
- std::experimental::flex_barrier`std::experimental::flex_barrier` is an experimental C++ barrier synchronization primitive whose completion function can change the required participant count for a later cycle.
- bitwise comparisonA bitwise comparison determines equality by comparing the object representations of values rather than applying their value-level comparison operators.
- C++ multithreading libraryThe C++ standard library facilities for creating and managing threads and coordinating concurrent execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
