LICENSE NEWS README TODO
SleepyPenguin Epoll Epoll::IO Ev EvFilt EventFD Inotify Inotify::Event Kevent Kqueue Kqueue::IO Note TimerFD VQ

Methods

::new #add #close #closed? #del #delete #events_for #flags_for #include? #io_for #mod #set #to_io #wait

class SleepyPenguin::Epoll

The Epoll class provides high-level access to epoll(7) functionality in the Linux 2.6 and later kernels. It provides fork and GC-safety for Ruby objects stored within the IO object and may be passed as an argument to IO.select.

Constants

CLOEXEC

specifies whether close-on-exec flag is set for Epoll.new

CTL_ADD

registers a target IO object via epoll_ctl

CTL_DEL

unregisters a target IO object via epoll_ctl

CTL_MOD

modifies the registration of a target IO object via epoll_ctl

ERR

watch for errors, there is no need to specify this, it is always monitored when an IO is watched

ET

notifications are only Edge Triggered, see epoll(7)

EXCLUSIVE

Sets an exclusive wakeup mode for the epoll object that is being attached to the target IO. This avoids thundering herd scenarios when the same target IO is shared among multiple epoll objects. Available since Linux 4.5

HUP

watch for hangups, there is no need to specify this, it is always monitored when an IO is watched

IN

watch for read/recv operations

ONESHOT

unwatch the descriptor once any event has fired

OUT

watch for write/send operations

PRI

watch for urgent read(2) data

RDHUP

Watch a specified io for shutdown(SHUT_WR) on the remote-end. Available since Linux 2.6.17.

WAKEUP

This prevents system suspend while event is ready. This requires the caller to have the CAP_BLOCK_SUSPEND capability Available since Linux 3.5

Public Class Methods

SleepyPenguin::Epoll.new([flags]) -> Epoll object source

Creates a new Epoll object with an optional flags argument. flags may currently be :CLOEXEC or 0 (or nil).

Public Instance Methods

add (io, events) source

Starts watching a given io object with events which may be an Integer bitmask or Array representing arrays to watch for.

ep.close -> nil source

Closes an existing Epoll object and returns memory back to the kernel. Raises IOError if object is already closed.

ep.closed? -> true or false source

Returns whether or not an Epoll object is closed.

ep.del(io) -> 0 source

Disables an IO object from being watched.

ep.delete(io) -> io or nil source

This method is deprecated and will be removed in sleepy_penguin 4.x

Stops an io object from being monitored. This is like Epoll#del but returns nil on ENOENT instead of raising an error. This is useful for apps that do not care to track the status of an epoll object itself.

This method is deprecated and will be removed in sleepy_penguin 4.x

epoll.events_for(io) -> Integer source

Returns the events currently watched for in current Epoll object. Mostly used for debugging.

Also aliased as: flags_for
flags_for (io) 

backwards compatibility, to be removed in 4.x


Alias for: events_for
epoll.include?(io) -> true or false source

Returns whether or not a given IO is watched and prevented from being garbage-collected by the current Epoll object. This may include closed IO objects.

ep.io_for(io) -> object source

Returns the given IO object currently being watched for. Different IO objects may internally refer to the same process file descriptor. Mostly used for debugging.

epoll.mod(io, flags) -> 0 source

Changes the watch for an existing IO object based on events. Returns zero on success, will raise SystemError on failure.

ep.set(io, flags) -> 0 source

This method is deprecated and will be removed in sleepy_penguin 4.x

Used to avoid exceptions when your app is too lazy to check what state a descriptor is in, this sets the epoll descriptor to watch an io with the given events

events may be an array of symbols or an unsigned Integer bit mask:

See constants in Epoll for more information.

This method is deprecated and will be removed in sleepy_penguin 4.x

to_io () source

Epoll objects may be watched by IO.select and similar methods

wait (maxevents = 64, timeout = nil) { |events, io| ... } source

Calls epoll_wait(2) and yields Integer events and IO objects watched for. maxevents is the maximum number of events to process at once, lower numbers may prevent starvation when used by epoll_wait in multiple threads. Larger maxevents reduces syscall overhead for single-threaded applications. maxevents defaults to 64 events. timeout is specified in milliseconds, nil (the default) meaning it will block and wait indefinitely.

As of sleepy_penguin 3.5.0+, it is possible to nest wait calls within the same thread.


Pages Classes Methods
mail archives: https://bogomips.org/sleepy-penguin/
public: sleepy-penguin@bogomips.org