Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
asio_main_loop.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
17  */
18 
19 #ifndef MIR_ASIO_MAIN_LOOP_H_
20 #define MIR_ASIO_MAIN_LOOP_H_
21 
22 #include "mir/main_loop.h"
23 
24 #include <boost/asio.hpp>
25 #include <memory>
26 #include <vector>
27 
28 namespace mir
29 {
30 
31 class AsioMainLoop : public MainLoop
32 {
33 public:
34  AsioMainLoop();
35  ~AsioMainLoop() noexcept(true);
36 
37  void run();
38  void stop();
39 
41  std::initializer_list<int> signals,
42  std::function<void(int)> const& handler);
43 
45  std::initializer_list<int> fd,
46  std::function<void(int)> const& handler);
47 
48 private:
49  class SignalHandler;
50  class FDHandler;
51 
52  boost::asio::io_service io;
53  std::vector<std::unique_ptr<SignalHandler>> signal_handlers;
54  std::vector<std::unique_ptr<FDHandler>> fd_handlers;
55 };
56 
57 }
58 
59 #endif /* MIR_ASIO_MAIN_LOOP_H */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013