unix::poll +linux +x86_64

unix::poll provides an interface for polling activity on file descriptors, compatible with the behavior defined by POSIX.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html

Index

Types

type event;
type pollfd;

Constants

const INDEF: time::duration;
const NONBLOCK: time::duration;

Functions

fn poll([]pollfd, time::duration) (uint | errors::error);

Types

type event[link]

type event = enum i16 {
	POLLIN = 1,
	POLLPRI = 2,
	POLLOUT = 4,
	POLLERR = 8,
	POLLHUP = 16,

};

Events bitfield for the events and revents field of pollfd.

type pollfd[link]

type pollfd = struct {
	fd: io::file,
	events: event,
	revents: event,
};

A single file descriptor to be polled.

Constants

def INDEF[link]

def INDEF: time::duration;

Pass this time::duration to poll to cause it wait indefinitely for the next event.

def NONBLOCK[link]

def NONBLOCK: time::duration;

Pass this time::duration to poll to cause it to return immediately if no events are available.

Functions

fn poll[link]

fn poll(fds: []pollfd, timeout: time::duration) (uint | errors::error);

Polls for the desired events on a slice of pollfds, blocking until an event is available, or the timeout expires. Set the timeout to INDEF to block forever, or NONBLOCK to return immediately if no events are available. Returns the number of pollfd items which have events, i.e. those which have revents set to a nonzero value.