BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
signals.cpp
Go to the documentation of this file.
1 #include <fc/asio.hpp>
2 #include <boost/asio/signal_set.hpp>
3 
4 namespace fc
5 {
6  std::shared_ptr<boost::asio::signal_set> set_signal_handler( std::function<void(int)> handler, int signal_num )
7  {
8  std::shared_ptr<boost::asio::signal_set> sig_set( new boost::asio::signal_set( fc::asio::default_io_service(),
9  signal_num) );
10  sig_set->async_wait( [sig_set,handler]( const boost::system::error_code& err, int num )
11  {
12  if( err != boost::asio::error::operation_aborted )
13  handler( num );
14  sig_set->cancel();
15  } );
16  return sig_set;
17  }
18 }
std::shared_ptr< boost::asio::signal_set > set_signal_handler(std::function< void(int)> handler, int signal_num)
Definition: signals.cpp:6
boost::asio::io_service & default_io_service()
Definition: asio.cpp:182
Definition: api.hpp:15