lib/io/epoll.rb in io-epoll-0.0.2 vs lib/io/epoll.rb in io-epoll-0.1.0

- old
+ new

@@ -1,12 +1,9 @@ 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) @@ -17,38 +14,8 @@ 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) - ios = ios.to_a - 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 - ep.close - else - evlist = ep.wait - ep.close - evlist end end end