Sha256: 6ca9244f8768016a1196f2473cf746d8be46737e1e6cfd7a8cbdc1c6b67cf2fd
Contents?: true
Size: 875 Bytes
Versions: 1
Compression:
Stored size: 875 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) 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
io-epoll-0.0.2 | lib/io/epoll.rb |