
Thanks guys for these answers. I am looking at the strand facility right now. I will do some testing and see if I can come up with something working :-) Any good examples to suggest? The one in http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html#boost... was using strand but there was no real need for it. On 28 September 2010 17:29, Tan, Tom (Shanghai) <TTan@husky.ca> wrote:
-----Original Message----- Date: Tue, 28 Sep 2010 11:18:22 +0800 From: Romain CHANU <romainchanu@gmail.com> To: boost@lists.boost.org Subject: [boost] [asio] Question regarding io_service.post() and pool of threads
Extracted from Boost Asio reference: "The io_service<http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/ref erence/io_service.html> guarantees that the handler will only be called in a thread in which the run(), run_one (), poll() or poll_one() member functions is currently being
invoked."
For my understanding, since there is a pool of threads, a handler can run concurrently in different threads, even though we are using io_service.post().
Is that correct? My concern here is about the need or not to lock the data accessed by the handler.
My understanding is that, it's another way to say that those calls won't create an additional thread while calling the completion handler having been registered by io_service.post(). Therefore, if io_service.run() itself is running in n threads, it's guaranteed all the registered completion handler will be invoked in at most n threads at random order, since there are only n threads in total .
-Tom
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost