Sha256: 33169aada8450c51b91d8976afd2f433c6e896430fa0d2616d41b4598cf682cd

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

class SleepyPenguin::Epoll::IO
  # :stopdoc:
  alias __epoll_wait epoll_wait
  undef_method :epoll_wait
  def epoll_wait(maxevents = 64, timeout = nil)
    begin
      if timeout == nil || timeout < 0 # wait forever
        begin
          IO.select([self])
          n = __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
        end while n == 0
      elsif timeout == 0
        return __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
      else
        done = Time.now + (timeout / 1000.0)
        begin
          tout = done - Time.now
          IO.select([self], nil, nil, tout) if tout > 0
          n = __epoll_wait(maxevents, 0) { |events,io| yield(events, io) }
        end while n == 0 && tout > 0
      end
      n
    rescue Errno::EINTR
      retry
    end
  end
  # :startdoc:
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sleepy_penguin-3.4.1 lib/sleepy_penguin/epoll/io.rb
sleepy_penguin-3.3.0 lib/sleepy_penguin/epoll/io.rb
sleepy_penguin-3.2.0 lib/sleepy_penguin/epoll/io.rb
sleepy_penguin-3.1.0.26.g7181 lib/sleepy_penguin/epoll/io.rb