SleepyPenguin Epoll Epoll::IO Ev EvFilt EventFD Inotify Inotify::Event Kevent Kqueue Kqueue::IO Note TimerFD VQ


::new #close #closed? #kevent #to_io

class SleepyPenguin::Kqueue

The high-level Kqueue interface. This provides fork-safety; as underlying kqueue descriptors are closed by the OS upon fork. This also provides memory protection from bugs due to not storing an external reference to an object, but still requires the user to store their own object references. Events registered to a Kqueue object cannot be shared across fork due to the underlying implementation of kqueue in *BSDs.

Public Class Methods

new () source

Initialize a new Kqueue object, this allocates an underlying Kqueue::IO object and may fail if the system is out of file descriptors or kernel memory

Public Instance Methods

kq.close -> nil source

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

kq.closed? -> true or false source

Returns whether or not an Kqueue object is closed.

kevent (changelist = nil, *args) { |kevent| ... } source

A high-level wrapper around Kqueue::IO#kevent Users are responsible for ensuring udata objects remain visible to the Ruby GC, otherwise ObjectSpace._id2ref may return invalid objects. Unlike the low-level Kqueue::IO#kevent, the block given yields only a single Kevent struct, not a 6-element array.

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

to_io () source

Kqueue objects may be watched by and similar methods

Pages Classes Methods
mail archives: