about summary refs log tree commit homepage
path: root/lib/rainbows/epoll.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-05 10:44:52 +0000
committerEric Wong <normalperson@yhbt.net>2011-02-05 11:13:43 +0000
commit90a86c9822238f01e8d60c9303b9a0da64351c7f (patch)
treeb13a4384b526887c964f74b1b9e2a2927e5b86bd /lib/rainbows/epoll.rb
parentc9ca82c76f1eb0e06b0aa204a243d00f382579c5 (diff)
downloadrainbows-90a86c9822238f01e8d60c9303b9a0da64351c7f.tar.gz
acceptor thread pools could use some work, still
Diffstat (limited to 'lib/rainbows/epoll.rb')
-rw-r--r--lib/rainbows/epoll.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/rainbows/epoll.rb b/lib/rainbows/epoll.rb
index b567142..075fcfb 100644
--- a/lib/rainbows/epoll.rb
+++ b/lib/rainbows/epoll.rb
@@ -12,11 +12,22 @@ module Rainbows::Epoll
   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.rerun
-    while obj = ReRun.shift
-      obj.epoll_run
-    end
+  def self.loop
+    timeout = Rainbows.server.timeout
+    begin
+      EP.wait(nil, timeout) { |flags, 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)