c++ - stopping an io_service object and boost::asio::io_service::work -
boost::asio::io_service m_io_service; boost::asio::io_service::work m_work(m_io_service); m_io_service.run() m_io_service.stop(); m_io_service.reset(); m_io_service.run(); //work object still used here or should recreate m_work object?
if stop io_service object, start again, need rebind work object ?
the canonical way have
optional<asio::io_service::work> m_work(asio::io_service::work(m_io_service));
or
shared_ptr<asio::io_service::work> m_work = make_shared<asio::io_service::work>(m_io_service);
so can, in both cases, signal "shutdown service using
m_work.reset();
and, no don't think need rebind work object. work objects not actual async operations. it's more refcount/lock
Comments
Post a Comment