Simple thread pool in C++

痞子三分冷 提交于 2019-12-30 10:44:13

问题


Could anyone point me to a sample implementation of a thread pool in C++, please? I'm looking for a very basic one without too much complexity, which would be suitable for a beginner in threading to study.


回答1:


Look at Intel's Thread Building Blocks. I don't know how well that library meets your "simple" criteria, but it seems to be very well thought-out and thorough. I would think that it would be worth the effort to learn if you want to do threading in C++.

Boost also has some threading facilities.




回答2:


It may be worth to check out Qt's QThreadPool implementation.




回答3:


This is a very good one : threadpool its built uppon boost so its cross platform and everything , very easy to use as well




回答4:


in his book Modern C++ Programming with Test-Driven Development, Jeff Langr walks thru a threadpool implementation. It's a busy wait implementation. I've modified it further here https://github.com/spakai/threadpool_future to support things such as signal-wait and futures.



来源:https://stackoverflow.com/questions/4179316/simple-thread-pool-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!