On 21/08/2010 04:30, John Millikin wrote:

This also changes the binary enumHandle to use non-blocking IO, as
recommended by Magnus Therning. I'm embarrassed to admit I still don't
understand the improvement, exactly, but three people so far have told
me it's a good idea.

The issue is that hGet always waits for a complete buffer-full of data before returning. The hWaitForInput/hGetNonBlocking combination fixes that problem, but you have to be careful to make sure that the Handle is in binary mode, otherwise hWaitForInput will not behave the way you expect (it will decode the input byte stream, and wait for a full character). For more information, see

http://hackage.haskell.org/trac/ghc/ticket/3808

A better fix is to use hGetBufSome, but (a) it is only available in GHC 6.14 which isn't released yet, and (b) there isn't a bytestring wrapper for it yet.

Cheers,
        Simon
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to