Concurrency Improvements in C++20: A Deep Dive
summary
C++20 adds concrete primitives and demos: atomic wait/notify and atomic<shared_ptr> so pointer ops avoid races, compare_exchange_strong loop is used to implement fetch_mul safely, and semaphores/latches/barriers replace many condition_variable uses. A producer/consumer works with atomic_flag wait/notify and with counting semaphores; a 1,000,000 ping‑pong benchmark shows condition_variable much slower while atomics and semaphores are far faster. Cooperative interruption (stop_token/source), std::jthread auto-join, and synchronized ostream flush on scope exit are shown working.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 1:10C++20 concurrency features
- 2:12Atomic ops and memory model
- 5:26Compare exchange strong
- 9:28Atomic flag and wait/notify
- 12:19Smart pointers and atomics
- 14:08Atomic reference guarantees
- 16:55Semaphores and producer-consumer
- 20:16Why avoid condition variables
- 27:48Ping-pong sync performance
- 34:26Choosing between atomics, semaphores, and condition variables
- 36:12Barriers and latches
- 39:25Barrier use cases
- 42:10Cooperative interruption
- 47:16Stop tokens in practice
- 51:24Improved std::thread
- 54:06Synchronized output streams
- 55:54Summary
- 56:15Q&A
related talks
01h 00mConcurrency in C++20: A Deep Dive
01h 24mConcurrency in C++20 and Beyond
01h 04mConcurrency in C++20 and Beyond
01h 07mThe C++20 Synchronization Library
01h 04mBack to Basics: Concurrency
01h 04mAtomics, Locks, and Tasks (part 2 of 2)
01h 28mC++ Memory Model: from C++11 to C++23
59mAn Introduction to Multithreading in C++20
