Memory ordering
Memory ordering is the set of rules governing the permitted ordering and visibility of memory operations across concurrent execution contexts.
C++ Concurrency in Action, Second Edition
The constraints governing how memory operations are ordered and observed across threads in the C++ memory model.
- How it is used
- Governs what atomic operations make observable across threads, particularly when publishing data or implementing lock-free structures.
- How deep it goes
- Works through contrasting ordering models and a lock-free stack’s success and retry paths, including the relationships each path requires.
- Examples
- Contrasts two-flag thread examples with a release-acquire flag handoff and a reference-counted lock-free stack.
- What you can do after
- Apply it via `std::atomic` memory-order arguments by deriving required happens-before relationships before weakening success or retry paths.
Read how C++ Concurrency in Action, Second Edition explains memory ordering →
Latency
Memory ordering is the set of rules governing the observable order in which memory operations become effective across concurrent execution contexts.
- How it is used
- Controls visibility and ordering in lock-free and wait-free concurrent algorithms.
- How deep it goes
- Explains CPU reordering, barrier roles, ordering modes, and a runnable invariant-violation example.
- Examples
- Uses Rust atomics, a value-and-done flag pair, repeated execution, and sorted output to expose an invariant violation.
- What you can do after
- Apply it via Rust or C++ atomic APIs to publish data safely between concurrent threads.
Related concepts
- sequential consistencyconfigures · Sequential consistency is a memory model in which participating operations appear in a single total order that preserves each thread’s program order.
- data raceaddresses · A data race is a concurrent access to shared data in which at least one access is a write and the accesses are not adequately synchronized.
- atomic operationconfigures · An atomic operation accesses or updates shared state as an indivisible action with respect to concurrent operations.
- std::memory_orderimplemented by · `std::memory_order` is a C++ standard library enumeration whose values specify memory-ordering constraints for atomic operations.
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.

