Boost logo

Boost :

Subject: Re: [boost] [asio] Question regarding io_service.post() and pool of threads
From: Romain CHANU (romainchanu_at_[hidden])
Date: 2010-09-28 21:45:17


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_asio.examples.http_server_3
was
using strand but there was no real need for it.

On 28 September 2010 17:29, Tan, Tom (Shanghai) <TTan_at_[hidden]> wrote:

> -----Original Message-----
> Date: Tue, 28 Sep 2010 11:18:22 +0800
> From: Romain CHANU <romainchanu_at_[hidden]>
> To: boost_at_[hidden]
> 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
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk