about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-07 20:09:50 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-07 20:12:22 -0800
commit7d07c36f1da30af054d78deed5e87f29832d6f6b (patch)
tree5b466654f6439dffc751889f624124d9121827cc /lib
parent31fe6e621ac3d84a091b468f26118d2226716e9b (diff)
downloadrainbows-7d07c36f1da30af054d78deed5e87f29832d6f6b.tar.gz
It'll make development of future ev_core-derived things
easier, hopefully.
Diffstat (limited to 'lib')
-rw-r--r--lib/rainbows/ev_core.rb4
-rw-r--r--lib/rainbows/event_machine.rb2
-rw-r--r--lib/rainbows/rev/client.rb2
-rw-r--r--lib/rainbows/rev/core.rb8
4 files changed, 9 insertions, 7 deletions
diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb
index 244e726..017fe5c 100644
--- a/lib/rainbows/ev_core.rb
+++ b/lib/rainbows/ev_core.rb
@@ -8,6 +8,10 @@ module Rainbows
     include Rainbows::Const
     G = Rainbows::G
 
+    def self.setup(klass)
+      klass.const_set(:APP, G.server.app)
+    end
+
     def post_init
       @remote_addr = ::TCPSocket === @_io ? @_io.peeraddr.last : LOCALHOST
       @env = {}
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index 7f77428..76085dc 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -191,9 +191,9 @@ module Rainbows
       EM.epoll
       EM.kqueue
       logger.info "EventMachine: epoll=#{EM.epoll?} kqueue=#{EM.kqueue?}"
-      Client.const_set(:APP, G.server.app)
       Server.const_set(:MAX, G.server.worker_connections +
                              HttpServer::LISTENERS.size)
+      EvCore.setup(Client)
       EM.run {
         conns = EM.instance_variable_get(:@conns) or
           raise RuntimeError, "EM @conns instance variable not accessible!"
diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb
index c9d058e..52ddaab 100644
--- a/lib/rainbows/rev/client.rb
+++ b/lib/rainbows/rev/client.rb
@@ -3,8 +3,6 @@ require 'rainbows/ev_core'
 module Rainbows
   module Rev
 
-    include Base
-
     class Client < ::Rev::IO
       include Rainbows::EvCore
       G = Rainbows::G
diff --git a/lib/rainbows/rev/core.rb b/lib/rainbows/rev/core.rb
index 0d1add5..0460137 100644
--- a/lib/rainbows/rev/core.rb
+++ b/lib/rainbows/rev/core.rb
@@ -20,6 +20,7 @@ module Rainbows
     end # class Server
 
     module Core
+      include Base
 
       # runs inside each forked worker, this sits around and waits
       # for connections and doesn't die until the parent dies (or is
@@ -27,10 +28,9 @@ module Rainbows
       def worker_loop(worker)
         init_worker_process(worker)
         mod = self.class.const_get(@use)
-        client = mod.const_get(:Client)
-        client.const_set(:APP, G.server.app)
-        Server.const_set(:MAX, G.server.worker_connections)
-        Server.const_set(:CL, client)
+        Server.const_set(:MAX, @worker_connections)
+        Server.const_set(:CL, mod.const_get(:Client))
+        EvCore.setup(EvCore)
         rloop = ::Rev::Loop.default
         Heartbeat.new(1, true).attach(rloop)
         LISTENERS.map! { |s| Server.new(s).attach(rloop) }