$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] boost::asio::io_service - cancel posted work
From: Christopher Pisz (cpisz_at_[hidden])
Date: 2011-10-06 13:08:16
Marat Abrarov <abrarov <at> mail.ru> writes:
>
> 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.