[Haskell-cafe] threadWaitRead and threadWaitWrite on multiple fds
aslatter at gmail.com
Mon Dec 13 02:14:13 CET 2010
On Sun, Dec 12, 2010 at 6:37 PM, 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.
> Would it be possible to create this functionality myself? Or do I need
> to request it and wait for a new GHC?
> It looks like the functionality I need is in System/Event/Thread.
> I think I can manage to write my own version of those functions which
> then loop through a list of fds, but the original file imports
> System/Event/Manager (registerFd, unregisterFd_) which I can't do
> because it's a hidden module.
> Is there a way around this?
Can you do it with forkIO? That is, have two light-weight threads,
each waiting on a different fd, which perform the same action when one
of them wakes up.
Maybe that would become too hard to synchronize the threads together,
but it might be the first thing to try before delving into GHC
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe