Boost logo

Boost :

Subject: [boost] RFC: Integrating Boost.Process and Boost.Asio
From: Boris (boriss_at_[hidden])
Date: 2008-10-03 11:07:58


I'm looking for ideas how to integrate Boost.Process and Boost.Asio. As of
today it is possible to use asynchronous I/O with Boost.Process. However
you have to pass around low-level file descriptors/HANDLEs like this:

bp::child c = start_child();
bp::pistream &is = c.get_stdout();
#if defined(BOOST_POSIX_API)
ba::posix::stream_descriptor in(io_service);
#elif defined(BOOST_WINDOWS_API)
ba::windows::stream_handle in(io_service);
#endif
in.assign(is.handle().release());
is.async_read_some(...);

It would be nice if you could write:

bp::child c = start_child();
bp::pistream &is = c.get_stdout();
is.async_read_some(...);

The first question is then where to pass the io_service instance to
Boost.Process? In Boost.Asio I/O objects are typically initialized with
io_service. As both child and pistream are created in the library
io_service would need to be passed to Boost.Process when the child is
spawned. However developers who don't want to use asynchronous I/O really
shouldn't create an io_service instance first.

If io_service is not passed to the constructor I wonder where to pass it
then? As far as I see there are no recommendations or guidelines in the
Boost.Asio documentation (probably because all I/O objects so far are
always initialized with io_service).

Another idea is of course adding a new class to Boost.Process (pistream
would then only be used for synchronous I/O)? Right now I'd probably go
this way?

Boris


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