Atomics, Locks, and Tasks (part 2 of 2)
summary
Compares raw threads, futures/promises, and task-based APIs and shows concrete fixes and numbers: a 100 million element inner product runs ~2.5–3 s single threaded and achieves about 8–10x speedup with C++17 parallel execution using std::async and std::transform with execution policies though Windows implementation limits vectorization, demonstrates joining bugs and the scope thread pattern and recommends std::jthread in C++20, explains condition variable pitfalls and shows promise/future transfers exceptions and single-use synchronization versus condition variables.
AI-written summary · about
chapters (16)
- 0:00Threats vs Tasks
- 1:30Threat Acne Error
- 2:45Threat Acne Example
- 4:50ScopeThreat
- 8:55Numbers
- 10:40Solutions
- 19:30Vectorization
- 21:30Overloads
- 23:25Transform with Use
- 24:55Data Race
- 26:20Implementation with Windows
- 27:35Parallel
- 31:50Conditionals
- 43:55Solution
- 45:45My preferred solution
- 59:25Exception in the promise
related talks
01h 08mBetter Code: Concurrency
59mAn Introduction to Multithreading in C++20
47mConcurrent Programming in C++
01h 00mConcurrency Improvements in C++20: A Deep Dive
47m“Multithreading is the answer. What is the question? (part 1 of 2)”
01h 04mBack to Basics: Concurrency
01h 00mConcurrency in C++20: A Deep Dive
01h 28mAn Introduction to Multithreading in C++20
