Boost logo

Boost Users :

Subject: [Boost-users] boost::asio::io_service - cancel posted work
From: Christopher Pisz (cpisz_at_[hidden])
Date: 2011-10-05 18:35:03


I posted an async_accept to my io_service.
The async_accept gets posted again to listen for incoming connections every
time it completes.

I was under the impression that calling io_service::stop, would be the way to
stop listening.

When debugging, I see that a function object was created when I called bind
inside my async_accept call.

That function object contains a smart pointer to the instance of the object to
whom the method to call back belongs.

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?

In debugging, the callback never gets called after stop, not does the
reference count in the smart pointer decrement.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net