]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (C) 2014 Ian Forbed |
2 | // Copyright (C) 2014 Vicente J. Botet Escriba | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | ||
8 | #ifndef BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP | |
9 | #define BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP | |
10 | ||
11 | #include <boost/thread/executors/detail/scheduled_executor_base.hpp> | |
12 | ||
13 | namespace boost | |
14 | { | |
15 | namespace executors | |
16 | { | |
17 | ||
18 | class scheduled_thread_pool : public detail::scheduled_executor_base<> | |
19 | { | |
20 | private: | |
21 | thread_group _workers; | |
22 | public: | |
23 | ||
24 | scheduled_thread_pool(size_t num_threads) : super() | |
25 | { | |
26 | for(size_t i = 0; i < num_threads; i++) | |
27 | { | |
28 | _workers.create_thread(bind(&super::loop, this)); | |
29 | } | |
30 | } | |
31 | ||
32 | ~scheduled_thread_pool() | |
33 | { | |
34 | this->close(); | |
35 | _workers.join_all(); | |
36 | } | |
37 | ||
38 | private: | |
39 | typedef detail::scheduled_executor_base<> super; | |
40 | }; //end class | |
41 | ||
42 | } //end executors namespace | |
43 | ||
44 | using executors::scheduled_thread_pool; | |
45 | ||
46 | } //end boost | |
47 | #endif | |
48 |