Why architecture matters here
Condition variables fail on spurious wakeups + lost wakeups. Architecture matters because mutex + predicate + notify compose.
Advertisement
The architecture: every piece explained
The top strip is basics. Mutex. Predicate. wait(mutex). notify_one / notify_all.
The middle row is patterns. Spurious wakeup. Wait loop. Producer. Timed wait.
The lower rows are ops. Lost wakeup. Metrics. Ops — correct usage + testing + timeout.
Advertisement
End-to-end flow
End-to-end: consumer locks mutex, checks queue empty, wait(mutex). Producer locks mutex, pushes item, notify_one, unlocks. Consumer wakes, re-checks predicate, dequeues.