Better Code: Concurrency
summary
Builds a C++14 reference task system from std::thread, std::mutex and condition_variable and shows how naive single-queue design performs horribly then improves performance ~100x with per-thread queues plus work stealing, reaching within 15% of Grand Central Dispatch. Argues for no raw synchronization primitives, documents how std::future/.get deadlocks on thread-pool tasks, and provides an experimental library adding continuations, joins, splits and cancellation. Demonstrates scale with a Fibonacci(1,000,000) example (≈29,000 digits, 72s single‑threaded).
AI-written summary · about
chapters (32)
- 0:00Intro
- 1:00Goals
- 3:30Lightroom for Web
- 5:55Definitions
- 7:14Synchronization Primitives
- 7:41Getting them wrong
- 10:52Fixing bugs
- 13:24Performance through parallelism
- 15:42Amdahls Law
- 18:03Mutex
- 28:15Tasking System
- 30:15C Implementation
- 35:40Task Stealing
- 37:24Push to Spin
- 40:01Live Dispatch
- 40:42CEO
- 42:11Tasking
- 43:36Power
- 47:12Marshaling Exceptions
- 47:38Blocking Threads
- 47:58Stops
- 48:55STD Future
- 50:47STD Sink
- 51:21STD Future Wait
- 52:03Warnings
- 53:36Fibonacci continuation
- 54:00Futures vs completion handlers
- 55:26Joins
- 57:45abort
- 58:04shared future
- 58:40split future
- 59:17promise
related talks
01h 04mAtomics, Locks, and Tasks (part 2 of 2)
59mAn Introduction to Multithreading in C++20
01h 04mBack to Basics: Concurrency
47mConcurrent Programming in C++
01h 07mThe C++20 Synchronization Library
01h 24mConcurrency in C++20 and Beyond
51mDevelopment of Multi-threaded applications
47m“Multithreading is the answer. What is the question? (part 1 of 2)”
