|Pathologically Eclectic Rubbish Lister|
Re: Synchronizing STDERR and STDOUTby nothingmuch (Priest)
|on Sep 21, 2006 at 11:27 UTC||Need Help??|
FWIW, why is TAPx::Parser wrapping around the stream? Why isn't a plumbing loop pulling from the stream and pushing to the parser?
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.
zz zZ Z Z #!perl