Boost logo

Boost :

Subject: Re: [boost] [gsoc] Boost.Process done
From: Boris Schaeling (boris_at_[hidden])
Date: 2010-09-11 16:47:12


On Sat, 11 Sep 2010 21:18:39 +0200, Jeremy Maitin-Shepard
<jeremy_at_[hidden]> wrote:

> [...]
>> Exactly! As there also can be only one signal handler while you can have
>> multiple Boost.Asio I/O service objects and I/O objects it gets even
>> more complicated. As we felt it's more difficult to use libraries from
>> different sources in one application when they all depend on SIGCHLD we
>> went with wait(). You still need to coordinate. But this is something
>> which we hope is easier to handle than libraries which steal signal
>> handlers from each other.
>
> I agree that using a separate thread reduces the need to coordinate with
> other code, but it seems that having one additional thread per process
> that is launched is an unreasonably high cost.

Maybe I misunderstand what you mean with process. But you need (and should
use) only one worker thread no matter for how many child processes you
wait. Your code can look like this:

boost::asio::io_service ioservice;
boost::process::status s(ioservice);
s.async_wait(child1.get_id(), handler);
s.async_wait(child2.get_id(), handler);
s.async_wait(child3.get_id(), handler);
...

There is only one worker thread within the ioservice object.

Boris


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