
Boris wrote:
On Sun, 31 Aug 2008 23:20:10 +0200, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
[...]I understand async I/O should be tied with ASIO. I think Boost.Iostreams
To give you an idea how asynchronous I/O with Boost.Process and Boost.Asio currently looks like:
boost::process::child child; // somehow launched #if defined(_WIN32) boost::asio::windows::stream_handle out(io_service, child.get_stdin().handle().release()); boost::asio::windows::stream_handle in(io_service, child.get_stdout().handle().release()); #else boost::asio::posix::stream_descriptor out(io_service, child.get_stdin().handle().release()); boost::asio::posix::stream_descriptor in(io_service, child.get_stdout().handle().release()); #endif in.async_read_some(...);
I don't know ASIO but it's a shame that it does not offer a portable interface for async I/O.
[...]I can wait ;-) Since you are working hard on the library, I think it's better to wait until you consider the library mature enough. Feel free to contact me if you have any question.
OK, I'll tell you once I'm done (as I said I expect until mid September). The code is nearly done. But with all the changes which I had to merge I definitely need to update the documentation and samples.
Ok.
By the way, I would be very interested in a communication channel between a parent and a child process based on Boost.Interprocess. I need asynchronous I/O though. Before I picked up Boost.Process I had created a Boost.Asio extension boost::asio::shared_memory which can be used like boost::asio::socket. The only (but big :) problem I haven't solved yet is how to handle more than one communication channel. As read/write operations in Boost.Interprocess need to be synchronized the calls might block. A parent process with many children will then have to use at least one thread per child. What would be required is a demultiplexer which would work like select() for file descriptors. Then I think asynchronous I/O could be done with Boost.Interprocess. The question is though what would that demultiplexer look like? You are not working on supporting asynchronous I/O in Boost.Interprocess? ;)
I don't have much idea about async I/O but we can try to write something once we know what we need. I might be completly wrong but boost::interprocess::shared_memory_object is based on a file descriptor (shm_open in unix and a plan file on windows) so we can just obtain the handle and see if select() and WaitForMultipleObject() work on them. After all, write() should work on UNIX with a shared memory object descritor. Regards, Ion