about summary refs log tree commit homepage
path: root/lib/rainbows/epoll/server.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-19 23:54:59 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-20 08:32:39 +0000
commit90af18f6884857704d72fd6b2bb91718aad72117 (patch)
tree3aad09eaac6d20d8f158d1fd7b1caad53f27ce2f /lib/rainbows/epoll/server.rb
parent5e4f790847198e1267b2fbd5decfa09e5cc3d618 (diff)
downloadrainbows-90af18f6884857704d72fd6b2bb91718aad72117.tar.gz
There's less logic in the server this way and easier
to potentially share code this way.
Diffstat (limited to 'lib/rainbows/epoll/server.rb')
-rw-r--r--lib/rainbows/epoll/server.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/rainbows/epoll/server.rb b/lib/rainbows/epoll/server.rb
index 58e7653..ab5a49f 100644
--- a/lib/rainbows/epoll/server.rb
+++ b/lib/rainbows/epoll/server.rb
@@ -2,16 +2,14 @@
 # :enddoc:
 module Rainbows::Epoll::Server
   @@nr = 0
-  Rainbows::Epoll.nr_clients = lambda { @@nr }
   IN = SleepyPenguin::Epoll::IN | SleepyPenguin::Epoll::ET
   MAX = Rainbows.server.worker_connections
   THRESH = MAX - 1
   LISTENERS = Rainbows::HttpServer::LISTENERS
-  EP = Rainbows::Epoll::EP
+  EP = Rainbows::EP
 
-  def self.run
-    LISTENERS.each { |sock| EP.add(sock.extend(self), IN) }
-    Rainbows::Epoll.loop
+  def self.nr
+    @@nr
   end
 
   # rearms all listeners when there's a free slot
@@ -19,6 +17,10 @@ module Rainbows::Epoll::Server
     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