From 90af18f6884857704d72fd6b2bb91718aad72117 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 May 2011 23:54:59 -0700 Subject: epoll/xepoll: more consistent client implementations There's less logic in the server this way and easier to potentially share code this way. --- lib/rainbows/xepoll/client.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/xepoll/client.rb') diff --git a/lib/rainbows/xepoll/client.rb b/lib/rainbows/xepoll/client.rb index c7eebcc..4f15a73 100644 --- a/lib/rainbows/xepoll/client.rb +++ b/lib/rainbows/xepoll/client.rb @@ -3,9 +3,7 @@ module Rainbows::XEpoll::Client N = Raindrops.new(1) - Rainbows::Epoll.nr_clients = lambda { N[0] } include Rainbows::Epoll::Client - EP = Rainbows::Epoll::EP ACCEPTORS = Rainbows::HttpServer::LISTENERS.dup extend Rainbows::WorkerYield @@ -26,8 +24,17 @@ module Rainbows::XEpoll::Client end end - def self.run - Rainbows::Epoll.loop + 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 || N[0] > 0 Rainbows::JoinThreads.acceptors(ACCEPTORS) end -- cgit v1.2.3-24-ge0c7