I've taken a cue from Arne's inotify module and have started working on
one for kqueue based systems. The code basically works but suffers from a
(imho) major drawback: it's not integrated with the Pike backend.
The inotify code slides nicely into the backend, primarily because inotify
presents itself as a standard fd with a read data event to indicate
events. kqueue, however, uses different event types monitored by kqueue.
Right now, a secondary kqueue loop can be run in a thread to wait for
events, but that seems pretty ugly to me. I'd like to find a better
approach.
An alternate approach might be to hook a second, immediate-timeout call to
kqueue() into the backend, similar to the GTK or ObjectiveC module. That's
a little better, as at least the end user sees a more consistent approach
to asynchronous events. Internally, I think it probably at least less
efficient, with other possible drawbacks.
I think the nicest approach would be to modify the kqueue backend so that
it can register VNODE, PROC and SIGNAL filters and shunt them off to an
appropriate handler. That, however, means that the backend would be split
again (creating a KqueueBackend or similar), with the new implementation
having different features.
If anyone's interested in looking at the code, it's available here:
https://bitbucket.org/hww3/public_system_kqueue/
I should note that I've commited some changes today away from my
development box, so it's likely that the last few revisions have errors
in them.
Does anyone else have thoughts about these approaches (or have an
alternate one?) Perhaps I've missed something obvious... it wouldn't be
the first time!
Best,
Bill