package miou
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=129339f4a60fc9579ee118d693056caf00be3b68c7a52ea974b91b1f25e4dd63
sha512=5603847cce524c04e9a5dca268fc1050fbf2e4019b0e7fa24ee3d4941c4dce38e17f49b39c7f812634d1ab9b4d0cb02c5103c8c0c644c174df48074763801ffd
doc/miou.unix/Miou_poll/index.html
Module Miou_pollSource
A direct binding of poll(2).
Main type for a poller.
has_ppoll is true if the system supports the ppoll(2) system call. Notably MacOS as of 2023 does not have it.
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.
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. If the system does not has_ppoll this call will raise Unix.Unix_error with ENOSYS. You most likely want to use ppoll_or_poll, see below.
A more portable ppoll(2) call
ppoll_or_poll t nfds tiemout is like ppoll if the system has_ppoll, otherwise the call is emulated via poll, notably the timeout is internally converted to milliseconds and there is no support for signal masking. You most likely want to use this instead of ppoll, the two calls are kept to prevent the user from expecting nanoseconds resolution from an emulated ppoll call.
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.