An Introduction to Multithreading in C++20
summary
C++20 gives concrete tools not platitudes: use std::jthread with std::stop_token for managed threads (destructor requests stop then joins), prefer parallel algorithms for bulk data, use a threadpool when tasks fit (no standard one yet), and synchronize with latch/barrier/future before falling back to mutex + condition_variable; semaphores for slot counting; atomics only when necessary. The talk demonstrates stop callbacks canceling blocking I/O and shows ordering of choices that preserve scalability and correctness.
AI-written summary · about
chapters (50)
- 0:00Introduction
- 0:52Agenda
- 1:15Why Multithreading
- 3:30Amdahls Law
- 5:54Parallel Algorithms
- 8:30Thread Pools
- 10:50Starting and Managing Threads
- 11:05Cancelling Threads
- 12:56Stop Requests
- 14:23Stoppable
- 15:12StopCallback
- 17:49JThread
- 20:32Destructor
- 21:40Thread
- 22:11References
- 22:40Structure semantics
- 23:15Stop source
- 23:41Stop source API
- 24:06Communication
- 24:24Data Race
- 25:24Latch
- 26:22Constructor
- 26:43Functions
- 28:07Tests
- 29:59Barrier
- 30:10Structural Barrier
- 31:22Template
- 32:29Completion Function
- 33:24Barrier Function
- 34:07Futures
- 34:19Promise
- 35:10Future
- 35:56Waiting
- 37:24Promises
- 38:11Exception
- 38:41Async
- 40:12Shared Future
- 40:50Mutex
- 43:12Does it work
- 44:19Explicit destruction
- 44:33Deadlock
- 44:52Waiting for data
- 45:09Busy wait
- 45:53Unique lock
- 47:58Notification
- 50:22Semaphore
- 52:03Number of Slots
- 52:48Atomics
- 54:21LockFree
- 55:14Summary
related talks
59mThreads and Locks must Go
01h 04m[old version]The C++20 Synchrononization Library
01h 04mThe C++20 Synchronization Library
52mBest Practices for Concurrency
49mThread Pool Elements
56mThe C++ Execution Model
57m[filtered] Asynchronous C++ Programming
59mMultithreading 101: Concurrency Primitives From Scratch
