Sha256: e295927eb2cdcf0cf32a576f212a0d503bc496e3e357a4feb59c4d748871bfbd
Contents?: true
Size: 814 Bytes
Versions: 1
Compression:
Stored size: 814 Bytes
Contents
require 'io/epoll/epoll' class IO class Epoll class Event < Struct.new(:data, :events) end class << self alias create new end def add(io, events) ctl(CTL_ADD, io, events) end def mod(io, events) ctl(CTL_MOD, io, events) end def del(io) ctl(CTL_DEL, io) end def closed? fileno < 0 end end def self.epoll(ios, events) open_len = ios.length ep = Epoll.create ios.each do |io| ep.add(io, events) end if block_given? while 0 < open_len evlist = ep.wait evlist.each do |ev| yield ev if ev.events & (Epoll::HUP|Epoll::ERR) open_len -= 1 ev.data.close end end end nil else ep.wait end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
io-epoll-0.0.1 | lib/io/epoll.rb |