[Haskell-cafe] threadWaitRead and threadWaitWrite on multiple fds

Johan Tibell johan.tibell at gmail.com
Mon Dec 13 08:17:56 CET 2010

On Mon, Dec 13, 2010 at 1:37 AM, Mathijs Kwik <bluescreen303 at gmail.com> wrote:
> Hi all,
> I read the paper about the new ghc7 event handling IO manager goodies.
> This is all very exciting stuff. I didn't know GHC's RTS had these
> smart async-IO facilities.
> The paper pointed me at threadWaitRead/threadWaitWrite.
> While very nice the way they are, I would also like to be able to wait
> on more than 1 fd until 1 of them becomes available.

You can fork a thread per fd and have the first thread that wakes up
kill the other threads using asynchronous exceptions. This is how e.g.
System.Timeout.timeout works.


More information about the Haskell-Cafe mailing list