Kea  2.1.7-git
io_service.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef ASIOLINK_IO_SERVICE_H
8 #define ASIOLINK_IO_SERVICE_H
9 
10 #include <boost/version.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <functional>
13 
14 namespace boost {
15 namespace asio {
16 #if BOOST_VERSION < 106600
17  class io_service;
18 #else
19  class io_context;
20  typedef io_context io_service;
21 #endif
22 }
23 }
24 
25 namespace isc {
26 namespace asiolink {
27 
28 class IOServiceImpl;
29 
33 class IOService {
39 
40 private:
41  IOService(const IOService& source);
42  IOService& operator=(const IOService& source);
43 public:
45  IOService();
47  ~IOService();
49 
54  void run();
55 
61  void run_one();
62 
67  void poll();
68 
72  void stop();
73 
77  bool stopped() const;
78 
80  void restart();
81 
84  void stopWork();
85 
92  boost::asio::io_service& get_io_service();
93 
103  void post(const std::function<void ()>& callback);
104 
105 private:
106  boost::shared_ptr<IOServiceImpl> io_impl_;
107 };
108 
110 typedef boost::shared_ptr<IOService> IOServicePtr;
111 
112 } // namespace asiolink
113 } // namespace isc
114 #endif // ASIOLINK_IO_SERVICE_H
Defines the logger used by the top-level component of kea-lfc.