diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-02-05 10:44:52 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-02-05 11:13:43 +0000 |
commit | 90a86c9822238f01e8d60c9303b9a0da64351c7f (patch) | |
tree | b13a4384b526887c964f74b1b9e2a2927e5b86bd /lib/rainbows/epoll.rb | |
parent | c9ca82c76f1eb0e06b0aa204a243d00f382579c5 (diff) | |
download | rainbows-90a86c9822238f01e8d60c9303b9a0da64351c7f.tar.gz |
acceptor thread pools could use some work, still
Diffstat (limited to 'lib/rainbows/epoll.rb')
-rw-r--r-- | lib/rainbows/epoll.rb | 19 |
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) |