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.