Fdhvdu / ThreadPool

A fastest, exception-safety and pure C++17 thread pool.
MIT License
130 stars 22 forks source link

Work stealing #7

Open oschonrock opened 4 years ago

oschonrock commented 4 years ago

Thank you for writing and publishing this thread pool implementation. It seems like a glaring hole in the C++ STL / Boost etc. As it stands std::async is totally unusable (runs "deferred" or one thread per task and blows up). C++20 offers "new futures", but no task launching/scheduling as far as I can see.

So a pool is totally necessary!

I noticed that your ReadMe says "TODO work stealing". Does you pool take this Sean Parent talk into account?

https://www.youtube.com/watch?v=zULU6Hhp42w&feature=emb_logo

This blog has a minimal implementation which does:

https://vorbrodt.blog/2019/02/27/advanced-thread-pool/ https://github.com/mvorbrodt/blog

Fdhvdu commented 4 years ago

Actually, there is a v2 version for this thread pool. I want to do a more flexible design for job selection (It just simply uses queue right now. But what if a user wants to specify which threads run next?) and some fancy features (but rare use cases). So, work stealing will be in the road map of v2 instead of this one.

I haven't watched the video and blog. I will take a look. Thanks for your information :) .

oschonrock commented 4 years ago

Thanks. Also I noticed that in your _Ret versiion you don't use std::future at all? Again see the video and the implementation on that blog.

Would make sense no?

Fdhvdu commented 4 years ago

CTask has a future inside, which is used in https://github.com/Fdhvdu/ThreadPool/blob/master/header/CThreadPoolItem_Ret.hpp#L25.

oschonrock commented 4 years ago

fair enough. thanks