liveBook · Manning

Wait-free data structure

As explained in C++ Concurrency in Action, Second Edition

A data structure whose operations guarantee that every accessing thread completes within a bounded number of steps, regardless of other threads’ behavior.

A wait-free data structure is lock-free and guarantees that every accessing thread completes an operation within a bounded number of steps, regardless of other threads’ behavior. section 7.1.3

Retrying compare-exchange

A compare-exchange loop with no bound on retries is not wait-free: clashes may force one thread to retry repeatedly while others progress. Wait-free designs require each operation to finish in a single pass, without one thread’s steps causing another operation to fail. section 7.1.3 section 7.1.2

Guaranteeing progress for every thread can make algorithms considerably more complex. Lock-free designs can enable concurrency and tolerate a thread dying mid-operation, but require careful handling of invariants, atomic modifications, and memory ordering. section 7.1.3 section 7.1.4

How C++ Concurrency in Action, Second Edition covers it

How deep it goes
Defines bounded completion, contrasts unbounded retries, and identifies single-pass execution as a difficult design requirement.
Examples
Contrasts unbounded compare-exchange loops with single-pass operations that cannot fail because of another thread’s steps.
What you can do after
Evaluate progress guarantees by checking whether operations can retry without a bound.
How it connects
Connects lock-free data structures with compare-exchange retries, starvation, and livelock.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of C++ Concurrency in Action, Second Edition. The section links point to the parts of the book it draws on.