]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/thread/executors/scheduled_thread_pool.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / thread / executors / scheduled_thread_pool.hpp
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/detail/config.hpp>
12 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION && defined BOOST_THREAD_PROVIDES_EXECUTORS && defined BOOST_THREAD_USES_MOVE
13
14 #include <boost/thread/executors/detail/scheduled_executor_base.hpp>
15
16 namespace boost
17 {
18 namespace executors
19 {
20
21 class scheduled_thread_pool : public detail::scheduled_executor_base<>
22 {
23 private:
24 thread_group _workers;
25 public:
26
27 scheduled_thread_pool(size_t num_threads) : super()
28 {
29 for(size_t i = 0; i < num_threads; i++)
30 {
31 _workers.create_thread(bind(&super::loop, this));
32 }
33 }
34
35 ~scheduled_thread_pool()
36 {
37 this->close();
38 _workers.interrupt_all();
39 _workers.join_all();
40 }
41
42 private:
43 typedef detail::scheduled_executor_base<> super;
44 }; //end class
45
46 } //end executors namespace
47
48 using executors::scheduled_thread_pool;
49
50 } //end boost
51 #endif
52 #endif
53