|
Boost Users : |
Subject: Re: [Boost-users] [boost-users][asio] timeout -isio_service.reset()safe with pool of threads?
From: tomasz jankowski (tomasz_jacek_at_[hidden])
Date: 2009-02-03 03:59:00
Exaclty. If you look at other asio examples you'll see the same pattern: async. operations are chained in the way that completion handler of a previous operation launches the next one. This pattern allows you to end the i/o in a very simple way: just break the above chain and the io_service.run() ends. Note also that if your handlers are made of some "connection" object (using shared_from_this, like in the examples) that encapsulates socket, then when the chain terminates, this object is automatically destroyed closing its socket.
However, such a simple design is not always possible. In more complicated cases you have to keep io_service running *always*, even when there's no i/o activity - until explicitly stopped. Refer to the following example to see how you can do this:
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