How to use the same thread pool batch by batch
问题 I found a good implementation of boost based thread pool which is an improvement over this and this . it is very easy to understand and test. It looks like this: #include <boost/thread/thread.hpp> #include <boost/asio.hpp> // the actual thread pool struct ThreadPool { ThreadPool(std::size_t); template<class F> void enqueue(F f); ~ThreadPool(); // the io_service we are wrapping boost::asio::io_service io_service; // dont let io_service stop boost::shared_ptr<boost::asio::io_service::work> work