Re: [Boost-users] boost::asio::io_service - cancel posted work

Hi, Christopher.
Since the callback never happens, my instance never gets destroyed.
How do I effectively cancel any outstanding work the io_service has posted to it, such that the smart pointer in the function object that the bind created will lose its reference count?
You can destroy io_service instance. asio::io_service::~io_service destroys all callbacks. Another solution is to close acceptor (and all other instances of asio::basic_io_object related to io_service instance), call asio::io_service::reset() and clear all queued callbacks by running them (asio::io_service::run/poll etc). Regards, Marat Abrarov.

Marat Abrarov
Hi, Christopher.
Since the callback never happens, my instance never gets destroyed.
How do I effectively cancel any outstanding work the io_service has posted
to
it, such that the smart pointer in the function object that the bind created will lose its reference count?
You can destroy io_service instance. asio::io_service::~io_service destroys all callbacks. Another solution is to close acceptor (and all other instances of asio::basic_io_object related to io_service instance), call asio::io_service::reset() and clear all queued callbacks by running them (asio::io_service::run/poll etc).
Regards, Marat Abrarov.
Thank you so much, all my problems just disappeared and my memory leak detector has applauded. The key was acceptor::close() I did a little dance.
participants (2)
-
Christopher Pisz
-
Marat Abrarov