about summary refs log tree commit homepage
path: root/lib/rainbows/epoll.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.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.rb')
-rw-r--r--lib/rainbows/epoll.rb24
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/rainbows/epoll.rb b/lib/rainbows/epoll.rb
index e4c956b..1a3427e 100644
--- a/lib/rainbows/epoll.rb
+++ b/lib/rainbows/epoll.rb
@@ -28,38 +28,22 @@ require 'sendfile'
 module Rainbows::Epoll
   # :stopdoc:
   include Rainbows::Base
-  ReRun = []
   autoload :Server, 'rainbows/epoll/server'
   autoload :Client, 'rainbows/epoll/client'
   autoload :ResponsePipe, 'rainbows/epoll/response_pipe'
   autoload :ResponseChunkPipe, 'rainbows/epoll/response_chunk_pipe'
-  class << self
-    attr_writer :nr_clients
-  end
-
-  def self.loop
-    begin
-      EP.wait(nil, 1000) { |_, obj| obj.epoll_run }
-      while obj = ReRun.shift
-        obj.epoll_run
-      end
-      Rainbows::Epoll::Client.expire
-    rescue Errno::EINTR
-    rescue => e
-      Rainbows::Error.listen_loop(e)
-    end while Rainbows.tick || @nr_clients.call > 0
-  end
 
   def init_worker_process(worker)
     super
-    Rainbows::Epoll.const_set :EP, SleepyPenguin::Epoll.new
-    Rainbows.at_quit { Rainbows::Epoll::EP.close }
+    Rainbows.const_set(:EP, SleepyPenguin::Epoll.new)
+    Rainbows.at_quit { Rainbows::EP.close }
     Rainbows::Client.__send__ :include, Client
+    LISTENERS.each { |io| io.extend(Server) }
   end
 
   def worker_loop(worker) # :nodoc:
     init_worker_process(worker)
-    Server.run
+    Client.loop
   end
   # :startdoc:
 end