Boost ASIO: recovering from handler exceptions
问题 If an ASIO callback throws an error is it safe to resume the async processing? In short, does the following code have any merit? void runAsioLoop() { boost::asio::io_service::work work(this->m_ioService); boost::system::error_code unused; while (m_running) { try { this->m_ioService.run(unused); this->m_ioService.reset(); } catch (...) { std::cerr << "*** An error happened\n"; } } } 回答1: It should work, but the better idiom is: for (;;) { try { svc.run(); break; // exited normally } catch (std