Kea: io_service.h Source File

| Kea 2.2.0

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
25namespace isc {
26namespace asiolink {
27
28class IOServiceImpl;
29
33 class IOService {
39
40private:
41 IOService(const IOService& source);
42 IOService& operator=(const IOService& source);
43public:
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
105private:
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
isc::asiolink::IOService
The IOService class is a wrapper for the ASIO io_service class.
Definition: io_service.h:33
isc::asiolink::IOService::run_one
void run_one()
Run the underlying event loop for a single event.
Definition: io_service.cc:142
isc::asiolink::IOService::~IOService
~IOService()
The destructor.
Definition: io_service.cc:133
isc::asiolink::IOService::run
void run()
Start the underlying event loop.
Definition: io_service.cc:137
isc::asiolink::IOService::IOService
IOService()
The constructor.
Definition: io_service.cc:130
isc::asiolink::IOService::get_io_service
boost::asio::io_service & get_io_service()
Return the native io_service object used in this wrapper.
Definition: io_service.cc:172
isc::asiolink::IOService::stop
void stop()
Stop the underlying event loop.
Definition: io_service.cc:152
isc::asiolink::IOService::restart
void restart()
Restarts the IOService in preparation for a subsequent run() invocation.
Definition: io_service.cc:162
isc::asiolink::IOService::stopped
bool stopped() const
Indicates if the IOService has been stopped.
Definition: io_service.cc:157
isc::asiolink::IOService::stopWork
void stopWork()
Removes IO service work object to let it finish running when all handlers have been invoked.
Definition: io_service.cc:167
isc::asiolink::IOService::poll
void poll()
Run the underlying event loop for a ready events.
Definition: io_service.cc:147
isc::asiolink::IOService::post
void post(const std::function< void()> &callback)
Post a callback to the end of the queue.
Definition: io_service.cc:177
asiolink
A wrapper interface for the ASIO library.
boost
Definition: io_service.h:14
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition: io_service.h:110
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143