Get Off My Thread: Techniques for Moving Work to Background Threads
summary
Argues that spawning a thread per event is hopeless and recommends either a dedicated background thread for ordered single threaded processing or a thread pool for scalable parallelism with explicit continuations to preserve ordering. Shows practical tools and patterns: std::thread std::jthread std::async stop token style cancellation via stop_token for cooperative cancellation, counting pending tasks plus atomic wait for shutdown, and posting GUI messages or eventfd to marshal progress updates back to the event loop.
AI-written summary · about
chapters (12)
- 0:00Intro
- 0:48Why do we need to move work off the current thread?
- 5:04Aside: Non-Blocking vs Lock-free
- 10:05Spawning new threads
- 11:37Managing thread handles
- 27:58Thread pools: upsides
- 29:42Thread pools: downsides
- 34:49Addressing thread pool downsides
- 39:42Cancellation: Stop tokens
- 42:22Cancellation: Counting outstanding tasks
- 49:37Coroutines: example
- 52:52Guidelines
related talks
59mAn Introduction to Multithreading in C++20
01h 28mAn Introduction to Multithreading in C++20
47m“Multithreading is the answer. What is the question? (part 1 of 2)”
01h 08mBetter Code: Concurrency
58mMultithreading with Qt
01h 31mstd::jthread - I Told You Concurrency Is Tricky
01h 04mAtomics, Locks, and Tasks (part 2 of 2)
57mHere’s my number; call me, maybe. Callbacks in a multithreaded world
