Boost Asio总结(13) 信号
Posted thefist11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Boost Asio总结(13) 信号相关的知识,希望对你有一定的参考价值。
1.1
eg.
typedef basic_signal_set signal_set;
void handler(
const boost::system::error_code& error,
int signal_number)
if (!error)
// A signal occurred.
...
// Construct a signal set registered for process termination.
boost::asio::signal_set signals(my_context, SIGINT, SIGTERM);
// Start an asynchronous wait for one of the signals to occur.
signals.async_wait(handler);
1.2
template <typename Executor = executor>
class basic_signal_set
void add(int signal_number)
boost::system::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number, ec);
boost::asio::detail::throw_error(ec, "add");
void remove(int signal_number)
boost::system::error_code ec;
impl_.get_service().remove(impl_.get_implementation(), signal_number, ec);
boost::asio::detail::throw_error(ec, "remove");
void clear()
boost::system::error_code ec;
impl_.get_service().clear(impl_.get_implementation(), ec);
boost::asio::detail::throw_error(ec, "clear");
void cancel()
boost::system::error_code ec;
impl_.get_service().cancel(impl_.get_implementation(), ec);
boost::asio::detail::throw_error(ec, "cancel");
template <typename SignalHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(SignalHandler,
void (boost::system::error_code, int))
async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
return async_initiate<SignalHandler, void (boost::system::error_code, int)>(
initiate_async_wait(), handler, this);
...
以上是关于Boost Asio总结(13) 信号的主要内容,如果未能解决你的问题,请参考以下文章
boost:asio信号量signal_set源码分析及使用