Chris@102: // Copyright (C) 2014 Ian Forbed Chris@102: // Copyright (C) 2014 Vicente J. Botet Escriba Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@102: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: Chris@102: #ifndef BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP Chris@102: #define BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP Chris@102: Chris@102: #include Chris@102: Chris@102: namespace boost Chris@102: { Chris@102: namespace executors Chris@102: { Chris@102: Chris@102: class scheduled_thread_pool : public detail::scheduled_executor_base<> Chris@102: { Chris@102: private: Chris@102: thread_group _workers; Chris@102: public: Chris@102: Chris@102: scheduled_thread_pool(size_t num_threads) : super() Chris@102: { Chris@102: for(size_t i = 0; i < num_threads; i++) Chris@102: { Chris@102: _workers.create_thread(bind(&super::loop, this)); Chris@102: } Chris@102: } Chris@102: Chris@102: ~scheduled_thread_pool() Chris@102: { Chris@102: this->close(); Chris@102: _workers.join_all(); Chris@102: } Chris@102: Chris@102: private: Chris@102: typedef detail::scheduled_executor_base<> super; Chris@102: }; //end class Chris@102: Chris@102: } //end executors namespace Chris@102: Chris@102: using executors::scheduled_thread_pool; Chris@102: Chris@102: } //end boost Chris@102: #endif Chris@102: