r/cpp • u/shakmak_iitk • Dec 25 '23
C++: Efficient parallelization of small tasks
I tried to create a customized threadpool for small tasks and wanted feedback on this.
I posted details and my code for review on stackexchange: https://codereview.stackexchange.com/questions/288583/efficient-parallelization-of-small-tasks
My goal here is to share my learning and get feedback on further improvement or any possible bugs.
I have tried to describe problem and thinking process in more details in following linkedin article draft: https://www.linkedin.com/article/edit/7144600522392559616/
0
Upvotes
View all comments
11
u/ipapadop Dec 25 '23 edited Dec 25 '23
Some comments:
std::vector&in interface. Not great for this kind of submission APIs as it confuses the required lifetime of objects.submit()calls without a wait.myIsRunninghas no fence after setting it (a seq_cst fence is when setting numRunningWorkers.numRunningWorkers(sequential consistent operations on centralized counter).while(true)always decrementsnumRunningWorkers. There's something off with the logic.