Re: [Boost-users] [Asio] Does stop() cancel handlers post()ed to io_service?
The program below gives different results on Windows (Visual Studio 2008) and Linux. While stop() does cancel the handlers on Linux, the same is not true for Windows. I also tried to destroy the io_service object instead of calling stop, but this does not cancel the handlers on either system, even though the documentation seems to state it should.
It would be more accurate to say "on Windows asio::io_service::stop()
does not cancel already queued (!) handlers". See example below.
~~~~~~~~~~~~~~~~~~~~~~~
#if defined(WIN32)
#include
Marat Abrarov wrote:
It would be more accurate to say "on Windows asio::io_service::stop() does not cancel already queued (!) handlers". See example below.
Your are right, of course. I should have been more specific. And chaining handlers like this is certainly another way to achieve the desired effect, thanks! However, I'm still interested whether stop() should always cancel the queued handlers, i.e. if this is a bug (on windows). The io_service documentation says this regarding the use of a work object (http://alturl.com/98rvq): "To effect a shutdown, the application will then need to call the io_service object's stop() member function. This will cause the io_service run() call to return as soon as possible, abandoning unfinished operations and without permitting ready handlers to be dispatched. Alternatively, if the application requires that all operations and handlers be allowed to finish normally, the work object may be explicitly destroyed." So am I misreading this or does this say io_service::stop() has to cancel all queued handlers? Regards, Martin
participants (2)
-
Marat Abrarov
-
Martin Gernhard