From 90a86c9822238f01e8d60c9303b9a0da64351c7f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 5 Feb 2011 10:44:52 +0000 Subject: *epoll: refactor common loop code acceptor thread pools could use some work, still --- lib/rainbows/xepoll/client.rb | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'lib/rainbows/xepoll/client.rb') diff --git a/lib/rainbows/xepoll/client.rb b/lib/rainbows/xepoll/client.rb index 2db684e..da0a0d1 100644 --- a/lib/rainbows/xepoll/client.rb +++ b/lib/rainbows/xepoll/client.rb @@ -2,12 +2,12 @@ # :enddoc: module Rainbows::XEpoll::Client + N = Raindrops.new(1) + Rainbows::Epoll.nr_clients = lambda { N[0] } include Rainbows::Epoll::Client MAX = Rainbows.server.worker_connections THRESH = MAX - 1 EP = Rainbows::Epoll::EP - N = Raindrops.new(1) - @timeout = Rainbows.server.timeout / 2.0 THREADS = Rainbows::HttpServer::LISTENERS.map do |sock| Thread.new(sock) do |sock| sleep @@ -25,24 +25,8 @@ module Rainbows::XEpoll::Client def self.run THREADS.each { |t| t.run } - begin - EP.wait(nil, @timeout) { |flags, obj| obj.epoll_run } - Rainbows::Epoll.rerun - Rainbows::Epoll::Client.expire - rescue Errno::EINTR - rescue => e - Rainbows::Error.listen_loop(e) - end while Rainbows.tick - - THREADS.delete_if do |thr| - Rainbows.tick - begin - thr.run - thr.join(0.01) - rescue - true - end - end until THREADS.empty? + Rainbows::Epoll.loop + Rainbows::JoinThreads.acceptors(THREADS) end # only call this once -- cgit v1.2.3-24-ge0c7