17 Dec 2007 redi   » (Master)

PStreams now has an improved implementation of pstreambuf::showmanyc() which makes streambuf::in_avail() far more useful. Previously it only worked on some platforms and although it would tell you how many characters could be read from the underlying pipe without blocking, if that number was less than the pstreambuf::bufsz then there was no way to read only that many characters from the streambuf without blocking. This is because underflow will try to fill the whole buffer, blocking until sufficient characters are available. (That behaviour actually makes in_avail() almost useless, I probably should have been doing avail -= avail%bufsz in the old showmanyc() code.)

The new showmanyc() code will immediately read as many characters as are available into the buffer, in non-blocking mode. This means that if you always check for available characters using streambuf::in_avail() and ensure you don't read more than that (e.g. by using istream::readsome() or istream::get()) then the parent process should never have to block waiting for data from the child.

The next step is to generalise this by providing a select()-like function, so you don't have to poll the two pipes connected to the child process' stdout and stderr. This is more important for the development branch where there could be any number of pipes shared between parent and child.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!