~/talk

Thread Pool Elements

Talkat Meeting C++ 2024 · 2024-11-14..11-16· [rust]
slides:none on file

Prototype thread pool implemented in C++20 inside Compiler Explorer uses a std::deque work queue, condition_variable, std::stop_source/stop_token and an atomic working counter, growing threads up to hardware_concurrency (which is two on Compiler Explorer). A real bug appears: capturing this in lambdas plus a resizing std::vector of thread contexts lets moved threads keep dangling pointers; reserving avoids it but doesn’t solve dynamic shrink/move. Sanitizers (thread sanitizer and memory sanitizer) catch the corruption; QThreadPool remains preferred for production.

AI-written summary · about

  1. 0:00Introduction
  2. 2:01Producer-consumer overview
  3. 3:01Simple thread-safe container
  4. 4:32Notification mechanisms
  5. 7:12Use cases and design
  6. 10:18Thread pool elements
  7. 13:09QThreadPool approach
  8. 14:51Execution context types
  9. 17:28Scaling and locking
  10. 18:07Mutex and sync details
  11. 20:48Mutex strategies
  12. 24:53Stop tokens and callbacks
  13. 31:44Memory and error handling
  14. 42:41Modern C++ execution
  15. 45:06Coroutines and conclusions
  16. 48:07Testing and future steps
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.