SignalDispatcher(const Args&... args) : _signal_set(_io_service, SIGINT, SIGTERM) , _thread(new std::thread(std::bind((IoServiceRunFunc)&IoService::run, &_io_service))) { std::size_t size = sizeof...(args); StopHandle res[sizeof...(args)] = {args...}; auto stop_func = [size, res] () { for (std::uint32_t i = 0; i < size; ++i) { res[i](); } LOG(INFO) << "Stop modules."; }; _signal_set.async_wait(std::bind(stop_func)); _thread->join(); }