Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] accepting all connections in a seperate thread - how?
From: for-gmane (for-gmane_at_[hidden])
Date: 2010-10-11 09:01:28


On 2010-10-11 08:59, Rutger ter Borg wrote:
> On 2010-10-11 03:16, for-gmane wrote:
>>
>> I think I've it similar to what you describe:
>> a pool of threads (5) all to run of the io_service's run() method,
>> and there is always an "outstanding" async_accept(), created even
>> before start()ing the session for the current connection.
>> Still, in the said scenario, none of the threads does handle the next
>> connection attempt as long as the current session is doing a lengthy job.
>> This is really funny.
>> I think, asio allows the threads to pick up a job only after returning
>> from the handler (ie. handle_read above). I'm not sure if that is not
>> too restrictive. I even tried to do socket_.get_io_service().poll();
>> right before the lengthy operation, but this didn't help either.
>
> AFAIK this is not the case; Asio doesn't do any dependency tracking of
> handlers, so new handlers should be executed immediately. Perhaps all
> your threads have run out of work (i.e., there's no work object attached
> to the io_service)? Have you tried posting your lengthy job to the task
> queue (io_service.post())?

Indeed! Using io_service.post() solves the problem!
Many thanks, very much appreciated!


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