Polling v0.1.0

Source
Descriptor flags and the epoll calls a poller waits with.

EpollEventBytes

// x86-64
pub const EpollEventBytes: uint = 12;

// AArch64
pub const EpollEventBytes: uint = 16;

The size of one epoll_event in bytes: its four-byte event mask, padding, and eight-byte word.

OverloadSummary
pub const EpollEventBytes: uint = 12;The size of one epoll_event in bytes: its four-byte event mask and eight-byte word, packed.
pub const EpollEventBytes: uint = 16;The size of one epoll_event in bytes: its four-byte event mask, padding, and eight-byte word.

Source

EpollEventWordOffset

// x86-64
pub const EpollEventWordOffset: uint = 4;

// AArch64
pub const EpollEventWordOffset: uint = 8;

Where the caller's word starts in an epoll_event.

Source

F_GETFL

pub const F_GETFL: int32 = 3;

F_GETFL: the fcntl command that reads a descriptor's status flags.

Source

F_SETFL

pub const F_SETFL: int32 = 4;

F_SETFL: the fcntl command that sets a descriptor's status flags.

Source

O_NONBLOCK

pub const O_NONBLOCK: int32 = 0x800;

O_NONBLOCK: the status flag that makes a call fail with EAGAIN rather than wait.

Source

EPOLL_CLOEXEC

pub const EPOLL_CLOEXEC: int32 = 0x80000;

EPOLL_CLOEXEC: close the epoll descriptor when the process starts another program.

Source

EPOLL_CTL_ADD

pub const EPOLL_CTL_ADD: int32 = 1;

EPOLL_CTL_ADD: register a descriptor.

Source

EPOLL_CTL_DEL

pub const EPOLL_CTL_DEL: int32 = 2;

EPOLL_CTL_DEL: remove a descriptor's registration.

Source

EPOLL_CTL_MOD

pub const EPOLL_CTL_MOD: int32 = 3;

EPOLL_CTL_MOD: change a registered descriptor's events and word.

Source

EPOLLIN

pub const EPOLLIN: uint32 = 0x1;

EPOLLIN: there is something to read, or a connection to accept.

Source

EPOLLOUT

pub const EPOLLOUT: uint32 = 0x4;

EPOLLOUT: a write would not wait.

Source

EPOLLERR

pub const EPOLLERR: uint32 = 0x8;

EPOLLERR: the descriptor has an error pending; always reported.

Source

EPOLLHUP

pub const EPOLLHUP: uint32 = 0x10;

EPOLLHUP: the peer has closed the connection; always reported.

Source

EPOLLRDHUP

pub const EPOLLRDHUP: uint32 = 0x2000;

EPOLLRDHUP: the peer has shut down its writing side.

Source

FcntlInt

pub func FcntlInt(
    fd: FileDescriptor,
    command: int32,
    argument: int64
) -> int64

Performs command on a descriptor with an integer argument.

See also: https://man7.org/linux/man-pages/man2/fcntl.2.html

Source

Parameters

NameTypeDescription
fdFileDescriptorthe descriptor
commandint32such as F_GETFL or F_SETFL
argumentint64the command's argument, or zero

Returns: the command's result, or a negative error number

EpollCreate1

pub func EpollCreate1(flags: int32) -> int64

Opens an epoll instance.

See also: https://man7.org/linux/man-pages/man2/epoll_create1.2.html

Source

Parameters

NameTypeDescription
flagsint32zero or EPOLL_CLOEXEC

Returns: the instance's descriptor, or a negative error number

EpollControl

pub func EpollControl(
    epoll: FileDescriptor,
    operation: int32,
    fd: FileDescriptor,
    event: *opaque
) -> int64

Adds, changes or removes the registration of fd with an epoll instance.

See also: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html

Source

Parameters

NameTypeDescription
epollFileDescriptorthe instance
operationint32EPOLL_CTL_ADD, EPOLL_CTL_MOD or EPOLL_CTL_DEL
fdFileDescriptorthe descriptor registered
event*opaqueEpollEventBytes bytes: the event mask and, at EpollEventWordOffset, the word to report; ignored when removing

Returns: zero, or a negative error number

EpollWait

pub func EpollWait(
    epoll: FileDescriptor,
    events: *var opaque,
    capacity: int32,
    timeout: int32
) -> int64

Waits until a registered descriptor is ready or timeout milliseconds pass, filling events with what is ready.

See also: https://man7.org/linux/man-pages/man2/epoll_wait.2.html

Source

Parameters

NameTypeDescription
epollFileDescriptorthe instance
events*var opaqueroom for capacity events of EpollEventBytes bytes each
capacityint32how many events fit
timeoutint32milliseconds to wait, zero to only look, or -1 to wait without end

Returns: how many events were filled, zero after the timeout, or a negative error number