]>
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_SCHEDULING_ADAPTOR_HPP | |
9 | #define BOOST_THREAD_EXECUTORS_SCHEDULING_ADAPTOR_HPP | |
10 | ||
11 | #include <boost/thread/executors/detail/scheduled_executor_base.hpp> | |
12 | ||
13 | namespace boost | |
14 | { | |
15 | namespace executors | |
16 | { | |
17 | ||
18 | template <typename Executor> | |
19 | class scheduling_adpator : public detail::scheduled_executor_base<> | |
20 | { | |
21 | private: | |
22 | Executor& _exec; | |
23 | thread _scheduler; | |
24 | public: | |
25 | ||
26 | scheduling_adpator(Executor& ex) | |
27 | : super(), | |
28 | _exec(ex), | |
29 | _scheduler(&super::loop, this) {} | |
30 | ||
31 | ~scheduling_adpator() | |
32 | { | |
33 | this->close(); | |
34 | _scheduler.join(); | |
35 | } | |
36 | ||
37 | Executor& underlying_executor() | |
38 | { | |
39 | return _exec; | |
40 | } | |
41 | ||
42 | private: | |
43 | typedef detail::scheduled_executor_base<> super; | |
44 | }; //end class | |
45 | ||
46 | } //end executors | |
47 | ||
48 | using executors::scheduling_adpator; | |
49 | ||
50 | } //end boost | |
51 | #endif |