Library
Module
Module type
Parameter
Class
Class type
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.
val create : unit -> t
val close : t -> unit
close t
closes the file descriptor underlying t
module Events : sig ... end
val add : t -> Unix.file_descr -> Events.t -> unit
add epoll fd events
registers fd
with epoll
to monitor for events
val upd : t -> Unix.file_descr -> Events.t -> unit
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.
val del : t -> Unix.file_descr -> unit
del epoll fd
unregister fd
from epoll
val wait : t -> int -> int -> (t -> Unix.file_descr -> Events.t -> unit) -> int
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.
val wait_fold :
t ->
int ->
int ->
'a ->
(t -> Unix.file_descr -> Events.t -> 'a -> 'a) ->
'a
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.
module EventFD : sig ... end
This module provides an interface to the eventfd(2) system call