Atomic_flag
An atomic flag is a standard atomic type representing a flag and providing indivisible operations to set or clear it for synchronization.
C++ Concurrency in Action, Second Edition
A C++ standard library atomic Boolean flag with test-and-set and clear operations.
- How it is used
- Uses a minimal lock-free Boolean atomic as a building block, including for implementing a spinlock mutex.
- How deep it goes
- Defines initialization and operations, explains memory-order constraints, and demonstrates a spinlock; broader atomic types are only contrasted.
- Examples
- Uses ATOMIC_FLAG_INIT, clear() and test_and_set(), then gives a spinlock mutex implementation.
- What you can do after
- Build a basic spinlock mutex by looping on acquire test_and_set() and unlocking with release clear().
Read how C++ Concurrency in Action, Second Edition explains atomic_flag →
Modern C
atomic_flag is a C atomic type that supports indivisible flag operations for concurrency and signal-related contexts.
- How it is used
- Communicates limited signal-related state between an asynchronous handler and the interrupted program.
- How deep it goes
- Defines observable indivisibility and availability, but does not develop atomic_flag syntax or operation details.
- Examples
- Uses a minimal signal handler that records interrupt state and returns, alongside conditional lock-free signal-call counting.
- What you can do after
- Apply it to communicate a small signal condition without making the handler perform uncontrolled program-state changes.
Related concepts
- atomic typekind of · An atomic type is a type whose supported accesses and operations are indivisible with respect to concurrent execution and provide defined synchronization semantics.
- signal handlerused by · A signal handler is a function or mechanism that specifies or performs a response when a signal or notification is delivered.
- spinlockimplements · A spinlock is a mutual-exclusion synchronization primitive in which a waiting thread repeatedly checks or attempts to acquire the lock rather than blocking.
- std::atomic<bool>alternative to · A C++ standard library atomic type that provides atomic operations on a Boolean value.
- lockless techniqueimplements · Lock-free is a concurrency progress property that guarantees some operation completes within a finite number of steps despite contention, without relying on mutual-exclusion locks.
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.

