From 6bde32081338ce8075854f4c47ce8ca5347df919 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Jan 2011 17:06:20 -0800 Subject: eliminate G constant and just use the Rainbows! module Code organization is hard :< --- lib/rainbows/event_machine.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/event_machine.rb') diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index cb76669..990a186 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -58,8 +58,9 @@ module Rainbows::EventMachine # given a INT, QUIT, or TERM signal) def worker_loop(worker) # :nodoc: init_worker_process(worker) - G.server.app.respond_to?(:deferred?) and - G.server.app = Rainbows::EventMachine::TryDefer[G.server.app] + server = Rainbows.server + server.app.respond_to?(:deferred?) and + server.app = TryDefer.new(server.app) # enable them both, should be non-fatal if not supported EM.epoll @@ -69,14 +70,14 @@ module Rainbows::EventMachine max = worker_connections + LISTENERS.size Rainbows::EventMachine::Server.const_set(:MAX, max) Rainbows::EventMachine::Server.const_set(:CL, client_class) - client_class.const_set(:APP, G.server.app) + client_class.const_set(:APP, Rainbows.server.app) Rainbows::EvCore.setup EM.run { conns = EM.instance_variable_get(:@conns) or raise RuntimeError, "EM @conns instance variable not accessible!" Rainbows::EventMachine::Server.const_set(:CUR, conns) EM.add_periodic_timer(1) do - unless G.tick + unless Rainbows.tick conns.each_value { |c| client_class === c and c.quit } EM.stop if conns.empty? && EM.reactor_running? end -- cgit v1.2.3-24-ge0c7