Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::asio::io_service - cancel posted work
From: Marat Abrarov (abrarov_at_[hidden])
Date: 2011-10-06 06:30:06

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).

Marat Abrarov.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at