12 #include <boost/enable_shared_from_this.hpp>
13 #include <boost/noncopyable.hpp>
14 #include <boost/asio/signal_set.hpp>
17 namespace ph = std::placeholders;
24 public boost::noncopyable {
46 void remove(
int signum);
50 boost::asio::signal_set signal_set_;
59 void callback(
const boost::system::error_code& ec,
int signum);
64 : signal_set_(io_service->get_io_service()), handler_(handler) {
68 IOSignalSetImpl::callback(
const boost::system::error_code& ec,
int signum) {
69 if (ec && ec.value() == boost::asio::error::operation_aborted) {
73 if (!ec && (signum > 0)) {
76 }
catch (
const std::exception& ex) {
83 signal_set_.async_wait(std::bind(&IOSignalSetImpl::callback,
84 shared_from_this(), ph::_1, ph::_2));
90 signal_set_.add(signum);
91 }
catch (
const boost::system::system_error& ex) {
93 "Failed to add signal " << signum <<
": " << ex.
what());
100 signal_set_.remove(signum);
101 }
catch (
const boost::system::system_error& ex) {
103 "Failed to remove signal " << signum <<
": " << ex.
what());
120 impl_->remove(signum);
IOSignalSet(asiolink::IOServicePtr io_service, IOSignalHandler handler)
Constructor.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
void remove(int signum)
Remove a signal from the list of signals to handle.
std::function< void(int signum)> IOSignalHandler
Defines a handler function for an IOSignal.
void install()
Install the callback on the IO service queue.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown when an unexpected error condition occurs.
IOSignalSetImpl(IOServicePtr io_service, IOSignalHandler handler)
Constructor.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void add(int signum)
Add a signal to the ASIO signal set.
A wrapper interface for the ASIO library.
Implementation class of IOSignalSet.
~IOSignalSetImpl()=default
Destructor.
void add(int signum)
Add a signal to the list of signals to handle.
void remove(int signum)
Remove a signal from the ASIO signal set.