One-shot semantics in GHC event manager

Ben Gamari bgamari.foss at gmail.com
Sat Oct 11 04:17:12 UTC 2014


In ba2555ef and a6f52b19 one-shot semantics were added to event manager
in `base`. If my understanding of this code is correct, in this mode the
event manager will use only notify the user of the first event on a
registered fd after which point the fd will need to be re-registered to
get another notification. It appears this was done to optimize the
common case of file I/O where only a single event is needed

This change lead to a regression[1] in Bas van Dijk's usb library under
GHC 7.8. usb's use of the event manager requires that all events on an
fd are reported until the fd is registered or else hardware events are
lost.

I'm a bit perplexed as to why the change was made in the way that it
was.  Making one-shot a event-manager-wide attribute seems to add a fair
bit of complexity to the subsystem while breaking backwards
compatibility with library code. Going forward library authors now need
to worry about whether the system event manager is one-shot or not. Not
only is this platform dependent but it seems that there is no way for a
user to determine which semantics the system event handler uses.

Is there a reason why one-shot wasn't exported as a per-fd attribute
instead of per-manager? Might it be possible to back out this change and
instead add a variant of `registerFd` which exposes one-shot semantics?

Cheers,

- Ben

 
[1] https://github.com/basvandijk/usb/issues/7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141011/adf79a79/attachment.sig>


More information about the ghc-devs mailing list