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 {
56 boost::asio::signal_set signal_set_;
65 void callback(
const boost::system::error_code& ec,
int signum);
70 : io_service_(io_service),
71 signal_set_(io_service_->getInternalIOService()),
85IOSignalSetImpl::callback(
const boost::system::error_code& ec,
int signum) {
86 if (ec && ec.value() == boost::asio::error::operation_aborted) {
90 if (!ec && (signum > 0)) {
93 }
catch (
const std::exception& ex) {
100 signal_set_.async_wait(std::bind(&IOSignalSetImpl::callback,
108 signal_set_.add(signum);
109 }
catch (
const boost::system::system_error& ex) {
111 "Failed to add signal " << signum <<
": " << ex.
what());
118 signal_set_.remove(signum);
119 }
catch (
const boost::system::system_error& ex) {
121 "Failed to remove signal " << signum <<
": " << ex.
what());
142 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.
void remove(int signum)
Remove a signal from the ASIO signal set.
IOSignalSetImpl(const IOServicePtr &io_service, IOSignalHandler handler)
Constructor.
void cancel()
Cancel the remaining installed signal handler callbacks.
~IOSignalSetImpl()
Destructor.
~IOSignalSet()
Destructor.
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(const 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.