package iomux
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Iomux.Poll
Source
A direct binding of poll(2).
Main type for a poller.
invalid_fd
is the Unix.file_descr
of value -1.
The actual poll(2) call
poll t nfds timeout
polls for the first nfds
, like the system call, invalid (-1) entries are ignored. The internal buffer is not modified after the call. It returns the number of ready file descriptors suitable to be used with iter_ready
.
The timeout parameter for ppoll
. Supports nanoseconds instead of milliseconds.
The actual ppoll(2) call
ppoll t nfds timeout sigmask
is like poll
but supports nanoseconds and a list of signals that are atomically masked during execution and restored uppon return.
set_index t index fd flag
modifies the internal buffer at index
to listen to flag
events of fd
. This overwrites any previous value of flag
and fd
internally. invalid_fd
(-1) can be used to deactivate the slot, but usage of invalidate_index
is preferred.
invalidate_index t index
modifies the internal buffer by invalidating index
. The kernel will ignore that slot. We also clear flags, just for kicks.
get_fd t index
is the file descriptor associated with index
.
iter_ready t nready fn
scans the internal buffer for every ready file descriptor and calls fn index fd flags
, the scanning is aborted after nready
entries are found. Invalid file descriptors (set to -1 via invalidate_index) are skipped. Typical usage is that nready
is the return of poll
or ppoll
. The internal buffer is left unmodified.