TRT
Sign in

Advanced · Module 12 · Lesson 5 of 5

Atomic Waiting, Notification and atomic_ref

Replace polling loops with atomic wait and notify, and understand when atomic_ref can retrofit atomic access to existing storage.

Pro — members onlyAbout 11 minutes

By the end you can

  • Use atomic wait and notify for efficient state changes
  • Explain why an atomic wait still needs a predicate loop
  • Describe atomic_ref alignment and lifetime requirements

Builds on Sanitizers and Tests: Proving the Pool Correct.

01 · A question first

A worker checks a flag a million times per second while nothing changes. The CPU burns power and still needs a memory-ordering rule. How can the worker sleep until the value changes, and can an existing integer be observed atomically without changing its type?

Make a guess before you read on.

02 · The idea

Members only

Unlock the full lesson

This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.

What's inside

  • Start with the problem
  • How the idea works
  • Why it is correct
  • What it costs
  • Pitfalls and variations
  • Production guidance

Something wrong with this lesson? Report a problem