Module: sys.poll

Source: ./sys/poll.reef


Overview

sys/poll - poll(2) event loop

Monitor multiple file descriptors for readability/writability events. Supports up to 64 file descriptors per poll set.

Example - Wait for readable pipe: poll_clear() let idx = poll_add(read_fd, POLLIN()) let ready = poll_wait(5000) // 5 second timeout if ready > 0 and poll_readable(idx) let data = fd_read(read_fd, 256) end if


Functions

fn poll_add(fd: int, events: int): int

Add fd to poll set with event mask Returns index for checking results

fn poll_wait(timeout_ms: int): int

Wait for events (timeout_ms: -1=block, 0=non-blocking, >0=ms) Returns number of ready fds, 0 on timeout

fn poll_revents(index: int): int

Get raw revents for fd at index

fn poll_readable(index: int): bool

Check if fd at index is readable

fn poll_writable(index: int): bool

Check if fd at index is writable

fn poll_error(index: int): bool

Check if fd at index has error

fn poll_hangup(index: int): bool

Check if fd at index has hangup

fn POLLIN(): int

Event constants

fn POLLOUT(): int

fn POLLERR(): int

fn POLLHUP(): int


Procedures

proc poll_clear()

Reset the poll fd set


Generated by reefc doc