package polly
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module PollySource
Module Polly provides access to the Linux epoll system call for monitoring a set of file descriptors for events that the client is interested in.
add epoll fd events registers fd with epoll to monitor for events
upd epoll fd events updates the events set of fd where fd has been previously been registered. upd is called mod in the Linux documentation but mod is already an infix operator in OCaml.
del epoll fd unregister fd from epoll
wait epoll max timeout f waits for events on the fds registered with epoll to happen or to return after timeout. When fds are found to be ready, wait iterates over them by calling f epoll fd events. f receives epoll, the fd being monitored, and the events. At most max fds are being iterated over by a call to wait. Note that still more than max fds could be ready to be processed - they would be handled by the next call to wait.
It is important to address the events that trigger an fd to be handled as otherwise the same fd will be handled again at the next call to wait, leading to a tight loop. This is worth checking using strace(1).
See the epoll_wait(2) manual page for the details of the system call.
wait_fold epoll max timeout init f works similar to wait except that function f additionally receives and produces a value of type 'a that is threaded through the invocations of f; the final value is returned.