Mutable shared state
Mutable shared state is data or computational state that multiple components or execution contexts can access and whose value can change over time.
C++ Concurrency in Action, Second Edition
Shared mutable data is information accessible by multiple threads that can also be modified during execution.
- How it is used
- Coordinates access to data shared between threads and highlights the rules needed to avoid concurrency bugs.
- How deep it goes
- Explains mutex protection, encapsulation, and pointer or reference backdoors through a shared-list example.
- Examples
- Uses an apartment-sharing analogy and a shared std::list<int> protected during list operations.
- What you can do after
- Apply std::mutex and std::lock_guard to guard shared-list operations, while designing interfaces that do not leak pointers or references.
Read how C++ Concurrency in Action, Second Edition explains mutable shared state →
100 Go Mistakes and How to Avoid Them
Mutable shared state is data that can be modified and is accessible by multiple parts of a program or concurrent executions.
- How it is used
- Controls time-dependent cache trimming in tests by making the current time replaceable.
- How deep it goes
- Explains how a global clock couples tests, then contrasts struct-level clock injection with caller-supplied timestamps.
- Examples
- Uses a cache that trims timestamped events, a global clock variable, and a fixed-time test dependency.
- What you can do after
- Apply clock injection or caller-supplied cutoffs to make time-dependent tests deterministic and isolated.
Read how 100 Go Mistakes and How to Avoid Them explains mutable shared state →
Related concepts
- integration testused by · An integration test evaluates whether multiple software components, or a component and an external dependency, interact and behave correctly together.
- threadused by · A thread is an independently schedulable sequence or context of execution within a program or process.
- actorused by · An actor is an independent entity or participant that performs actions, maintains or pursues state or goals, and interacts with other entities or systems.
- synchronizationconfigured by · Synchronization coordinates operations, events, clocks, data, or states to establish required timing, ordering, visibility, or consistency relationships.
- immutable collectionaddressed by · An immutable collection is a collection whose membership and contents cannot be changed after creation.
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.

