summary refs log tree commit homepage
path: root/lib/rainbows/event_machine.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-05 17:06:20 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-06 07:17:19 +0000
commit6bde32081338ce8075854f4c47ce8ca5347df919 (patch)
tree71759032be458838eb33f7951172e8572aec4b6d /lib/rainbows/event_machine.rb
parentd6e4975937a9590f48dc39b1a4aefa9d62f34616 (diff)
Code organization is hard :<
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r--lib/rainbows/event_machine.rb9
1 files changed, 5 insertions, 4 deletions
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