Boost logo

Boost :

Subject: Re: [boost] [asio] Question regarding io_service.post() and pool of threads
From: Tan, Tom (Shanghai) (TTan_at_[hidden])
Date: 2010-09-28 05:29:38


-----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


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