Polling v0.1.0
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.
| Overload | Summary |
|---|---|
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. |
EpollEventWordOffset
// x86-64
pub const EpollEventWordOffset: uint = 4;
// AArch64
pub const EpollEventWordOffset: uint = 8;
Where the caller's word starts in an epoll_event.
F_GETFL
pub const F_GETFL: int32 = 3;
F_GETFL: the fcntl command that reads a descriptor's status flags.
F_SETFL
pub const F_SETFL: int32 = 4;
F_SETFL: the fcntl command that sets a descriptor's status flags.
O_NONBLOCK
pub const O_NONBLOCK: int32 = 0x800;
O_NONBLOCK: the status flag that makes a call fail with EAGAIN rather than wait.
EPOLL_CLOEXEC
pub const EPOLL_CLOEXEC: int32 = 0x80000;
EPOLL_CLOEXEC: close the epoll descriptor when the process starts another program.
EPOLL_CTL_ADD
pub const EPOLL_CTL_ADD: int32 = 1;
EPOLL_CTL_ADD: register a descriptor.
EPOLL_CTL_DEL
pub const EPOLL_CTL_DEL: int32 = 2;
EPOLL_CTL_DEL: remove a descriptor's registration.
EPOLL_CTL_MOD
pub const EPOLL_CTL_MOD: int32 = 3;
EPOLL_CTL_MOD: change a registered descriptor's events and word.
EPOLLIN
pub const EPOLLIN: uint32 = 0x1;
EPOLLIN: there is something to read, or a connection to accept.
EPOLLOUT
pub const EPOLLOUT: uint32 = 0x4;
EPOLLOUT: a write would not wait.
EPOLLERR
pub const EPOLLERR: uint32 = 0x8;
EPOLLERR: the descriptor has an error pending; always reported.
EPOLLHUP
pub const EPOLLHUP: uint32 = 0x10;
EPOLLHUP: the peer has closed the connection; always reported.
EPOLLRDHUP
pub const EPOLLRDHUP: uint32 = 0x2000;
EPOLLRDHUP: the peer has shut down its writing side.
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
Parameters
| Name | Type | Description |
|---|---|---|
fd | FileDescriptor | the descriptor |
command | int32 | such as F_GETFL or F_SETFL |
argument | int64 | the 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
Parameters
| Name | Type | Description |
|---|---|---|
flags | int32 | zero 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
Parameters
| Name | Type | Description |
|---|---|---|
epoll | FileDescriptor | the instance |
operation | int32 | EPOLL_CTL_ADD, EPOLL_CTL_MOD or EPOLL_CTL_DEL |
fd | FileDescriptor | the descriptor registered |
event | *opaque | EpollEventBytes 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
Parameters
| Name | Type | Description |
|---|---|---|
epoll | FileDescriptor | the instance |
events | *var opaque | room for capacity events of EpollEventBytes bytes each |
capacity | int32 | how many events fit |
timeout | int32 | milliseconds 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