Better Code: Concurrency - Sean Parent
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about thread pools, synchronization overhead, async performance and future cancellation in C++.
Recommended by 2 people across 2 different months, 2017 to 2021.
What it is
Sean Parent's NDC London talk on writing concurrent C++ that avoids waiting and blocking. He uses C++14 primitives to build a simple reference task system (thread pool with queues) and explains why raw threads, mutexes and std::async fall short.
What people said
Strong rec alagner · 2021-03 · Stack Overflow · on “In c++, Any cross thread synchronisation method that cause major overhead only on write?”
Have you seen Sean Parent's talk on task systems? If not, I can highly recommend it, I guess you might find some techniques presented there useful, as it's more than a question of a single synchronization primitive [this video]
Recommends Quuxplusone · 2017-07 · Stack Overflow · on “How can I propagate exceptions between threads?”
4 years later, my answer has not aged well. :) Re "Why": I think it was just for clarity (to show that `async` returns a future rather than something-else). Re "Also, is there": Not in `std::future`, but see Sean Parent's talk "Better Code: Concurrency" [this video] or my "Futures from Scratch" [LINK] for different ways to implement that if you don't mind rewriting the entire STL for starters. :) The key search term is "cancellation."
Cites Diconica · 2021-12 · Stack Overflow · on “Multi Processing member function of a class store in array in python”
Thanks, Booboo. I figured out the issue with the Class and Instance variables when you @classmethod. The way its done in the C++ engine. We generate the pool at the start of the program in the game class. We use one per process core. Then we split the load among the processes each loop. Each thread or process has its own que we can dump the tasks into. That way the work is divided among the CPUs. Sean Parent has a good video covering the performance differences. [this video] Without async the time is 1.53e-6 Async actually slows it down.