Sha256: e2ae949f605bd3b4a61f4ac76b8171844ca8c3611475d342c0c65650530447ad

Contents?: true

Size: 758 Bytes

Versions: 23

Compression:

Stored size: 758 Bytes

Contents

# -*- encoding: binary -*-
# :enddoc:
module Rainbows::Epoll::Server
  @@nr = 0
  IN = SleepyPenguin::Epoll::IN | SleepyPenguin::Epoll::ET
  MAX = Rainbows.server.worker_connections
  THRESH = MAX - 1
  LISTENERS = Rainbows::HttpServer::LISTENERS
  EP = Rainbows::EP

  def self.nr
    @@nr
  end

  # rearms all listeners when there's a free slot
  def self.decr
    THRESH == (@@nr -= 1) and LISTENERS.each { |sock| EP.set(sock, IN) }
  end

  def self.extended(sock)
    EP.set(sock, IN)
  end

  def epoll_run
    return EP.delete(self) if @@nr >= MAX
    while io = kgio_tryaccept
      @@nr += 1
      # there's a chance the client never even sees epoll for simple apps
      io.epoll_once
      return EP.delete(self) if @@nr >= MAX
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rainbows-5.2.1 lib/rainbows/epoll/server.rb
rainbows-5.2.0 lib/rainbows/epoll/server.rb
rainbows-5.1.1 lib/rainbows/epoll/server.rb
rainbows-5.1.0 lib/rainbows/epoll/server.rb
rainbows-5.0.0.5.ge717 lib/rainbows/epoll/server.rb
rainbows-5.0.0 lib/rainbows/epoll/server.rb
rainbows-4.7.0 lib/rainbows/epoll/server.rb
rainbows-4.6.2 lib/rainbows/epoll/server.rb
rainbows-4.6.1 lib/rainbows/epoll/server.rb
rainbows-4.6.0.4.g4108 lib/rainbows/epoll/server.rb
rainbows-4.6.0 lib/rainbows/epoll/server.rb
rainbows-4.5.0 lib/rainbows/epoll/server.rb
rainbows-4.4.3 lib/rainbows/epoll/server.rb
rainbows-4.4.2 lib/rainbows/epoll/server.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/epoll/server.rb
rainbows-4.4.1 lib/rainbows/epoll/server.rb
rainbows-4.4.0 lib/rainbows/epoll/server.rb
rainbows-4.3.1 lib/rainbows/epoll/server.rb
rainbows-4.3.0 lib/rainbows/epoll/server.rb
rainbows-4.2.0 lib/rainbows/epoll/server.rb