in reply to Synchronizing STDERR and STDOUT
Then you don't necessarily need nonblocking reads, etc at the IO level - you could push that down to POE or whatever.
XML::Parser has a non blocking interface which i've always liked due to it's simplicity - you just push strings when you have them, and it generates events. If you put in a partial string then the parser's state machine will simply be in that state waiting for more input.
This way you can have e.g. TAPx::Parser::Harness::Win32, *Socket, *POE, *Whatever, all reusing the parser without needing to model an iterator API around the various platform specific quirks.
Update: to clarify that last part - you only truely need non blocking IO if you need to parse multiple streams simultaneously, and as long as the parser has a push api flexible enough to be reentrant (multiple parsers instantiated and with their own state simultaneously) then there's no reason why it can't deliver callbacks in only when it's ready.
Update 2: POE::Filter::XML is written over XML::SAX::Expat::Incremental which is basically a SAX wrapper for the ExpatNB interface. That might be a nice example.
zz zZ Z Z #!perl
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Synchronizing STDERR and STDOUT
by Ovid (Cardinal) on Sep 21, 2006 at 13:39 UTC | |
by nothingmuch (Priest) on Sep 21, 2006 at 18:37 UTC | |
Re^2: Synchronizing STDERR and STDOUT
by nicholasrperez (Monk) on Sep 21, 2006 at 13:48 UTC |