Kea 3.1.1
io_service.h
Go to the documentation of this file.
1// Copyright (C) 2011-2025 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#include <list>
14
15#if BOOST_VERSION < 106600
16#error "Boost ASIO older than 1.66 are not supported"
17#endif
18
19#include <boost/asio/io_context.hpp>
20
21namespace isc {
22namespace asiolink {
23
24class IOServiceImpl;
25class IOService;
26
28typedef boost::shared_ptr<IOService> IOServicePtr;
29
32class IOService {
37
38private:
39 IOService(const IOService& source);
40 IOService& operator=(const IOService& source);
41public:
43 IOService();
44
46 ~IOService();
48
53 void run();
54
62 size_t runOne();
63
78 size_t runOneFor(size_t wait_time_usecs, bool& timed_out);
79
86 size_t poll();
87
94 size_t pollOne();
95
99 void stop();
100
104 bool stopped() const;
105
107 void restart();
108
111 void stopWork();
112
121 boost::asio::io_context& getInternalIOService();
122
132 void post(const std::function<void ()>& callback);
133
137 void stopAndPoll(bool ignore_errors = true);
138
139private:
140
142 boost::shared_ptr<IOServiceImpl> io_impl_;
143};
144
145} // namespace asiolink
146} // namespace isc
147
148#endif // ASIOLINK_IO_SERVICE_H
Defines the logger used by the top-level component of kea-lfc.