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

Methods

::new #kevent

class SleepyPenguin::Kqueue::IO

Kqueue::IO is a low-level class. It does not provide fork nor GC-safety, so Ruby IO objects added via kevent must be retained by the application until IO#close is called.

Warning: this class is easy to misuse, be careful as failure to preserve references objects passed as Kevent#udata may lead to crashes in Ruby. The high-level Kqueue class prevents these crashes (but may still return invalid objects).

Public Class Methods

SleepyPenguin::Kqueue::IO.new        -> Kqueue::IO object source

Creates a new Kqueue::IO object. This is a wrapper around the kqueue(2) system call which creates a Ruby IO object around the kqueue descriptor.

kqueue descriptors are automatically invalidated by the OS across fork, so care must be taken when forking. Setting IO#autoclose=false is recommended for applications which fork after kqueue creation.

Public Instance Methods

kq_io.kevent([changelist[, nevents[, timeout]]]) { |ident,filter,flags,fflags,data,udata| ... } source

This is a wrapper around the kevent(2) system call to change and/or retrieve events from the underlying kqueue descriptor.

changelist may be nil, a single Kevent struct or an array of Kevent structs. If changelist is nil, no changes will be made to the underlying kqueue object.

nevents may be non-negative integer or nil. If nevents is zero or nil, no events are retrieved. If nevents is positive, a block must be passed to kevent for each event.

timeout is the numeric timeout in seconds to wait for nevents. If nil and nevents is positive, kevent will sleep forever. timeout may be in a floating point number if subsecond resolution is required. If nevents is nil or zero and timeout is not specified, timeout is implied to be zero.

If event retrieval is desired, a block taking 6-elements (one for each field of the kevent struct) must be passed.

Parent: IO
Pages Classes Methods


mail archives: https://yhbt.net/sleepy-penguin/
public: sleepy-penguin@yhbt.net
source code: git clone https://yhbt.net/sleepy_penguin.git