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