0

I see there's wrapper libraries for select(2) and poll(2), but they don't seem much used.

The epoll-based System.Event used here has since been merged in as GHC.Event (though the loop function got put in to the private module GHC.Event.Manager and isn't exported, so apparently only getSystemEventManager is usable). GHC.Event says "This module should be considered GHC internal.", which has me wondering - is there some library that wraps that that I should be using, instead?

Some background on my use-case: I wanted to perform an action on a udev event (update a display when e.g. brightness changes). The example here is using the select(2) wrapper: https://github.com/pxqr/udev/blob/master/examples/monitor.hs#L36 I was hoping to use something more modern / better maintained and/or less dependencies.

pdxleif
  • 1,750
  • 16
  • 15
  • Turns out there's `threadWaitRead` and `threadWaitWrite` in `Control.Concurrent` to block the current thread until a file descriptor is ready for reading / writing, without actually doing reading or writing. – pdxleif May 17 '18 at 06:02
  • 1
    Note that the GHC runtime automatically uses `poll` when Haskell threads (which might be run on a single OS thread) are stuck. The usual solution is to forget about `poll` and `forkIO` may green threads doing blocking I/O, and let the GHC runtime call `poll` for you. The functions you mention also help, if you do not want to read right now. – chi May 17 '18 at 10:22

0 Answers0