std::jthread - I Told You Concurrency Is Tricky
summary
C++ gains a practical thread type that auto-joins on destruction and adds cooperative cancellation: the team implements std::jthread with a paired stop_token/stop_source and a condition_variable_any interruptible wait. Implementers use stop callbacks, move-safe token copies, and inner mutexes to avoid deadlocks and races; early bugs include tokens moved out of members and lock-order deadlocks, both fixed. The design ships in C++20 and works for typical threaded and condition-variable use.
AI-written summary · about
chapters (12)
- 0:00Start
- 1:06Disclaimer
- 14:40The Design
- 19:36Cooperative Cancellation of a Threat
- 21:49Options To Cancel a Threat
- 37:11General Api
- 43:35Condition Variables
- 1:05:07Condition Variable
- 1:08:24Deadlock
- 1:11:36Change the Order of Unlocks by Move by Creating a New Lock Guard
- 1:26:31What Would Happen if the Callback Fades To Be Registered due to Running out of Heat Memory
- 1:26:47What Happens to the Stop Callbacks When J Threat Detached His Call
related talks
01h 04mConcurrency in C++20 and Beyond
01h 28mAn Introduction to Multithreading in C++20
01h 04mBack to Basics: Concurrency
01h 03mGet Off My Thread: Techniques for Moving Work to Background Threads
47mConcurrent Programming in C++
59mAn Introduction to Multithreading in C++20
01h 08mBetter Code: Concurrency
01h 00mConcurrency in C++20: A Deep Dive
