Parent

Namespace

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 an IO object via epoll_ctl

CTL_DEL

unregisters an IO object via epoll_ctl

CTL_MOD

modifies the registration of an 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)

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

Attributes

to_io[R]

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

Public Class Methods

SleepyPenguin::Epoll.new([flags]) → Epoll object view method 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) view method source

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

close → nil view method source

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

closed? → true or false view method source

Returns whether or not an Epoll object is closed.

del(io) → 0 view method source

Disables an IO object from being watched.

delete(io) → io or nil view method 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

events_for(io) → Integer view method source

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

Also aliased as: flags_for
flags_for(io) view method source

backwards compatibility, to be removed in 4.x

Alias for: events_for
include?(io) → true or false view method 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.

io_for(io) → object view method 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.

mod(io, flags) → 0 view method source

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

set(io, flags) → 0 view method 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:

  • events = [ :IN, :ET ]

  • events = SleepyPenguin::Epoll::IN | SleepyPenguin::Epoll::ET

See constants in Epoll for more information.

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

wait(maxevents = 64, timeout = nil) view method 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.

Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.

We love to hear from you!
Email patches (with git send-email), pull requests, questions, bug reports, suggestions, etc. to us publically at sleepy.penguin@librelist.org.
To subscribe, just send any email to sleepy.penguin@librelist.org, and respond to the automated confirmation message.
Do not waste bandwidth with HTML, HTML mail will not be read.
Quote only parts you're responding to and do not top post.
For sensitive topics, email us privately at sleepy.penguin@bogomips.org.