event_machine: avoid close on deferred response
[rainbows.git] / lib / rainbows / coolio_fiber_spawn.rb
blob8527656cbd9e5246f3b44ec35012f12879c4e778
1 # -*- encoding: binary -*-
2 require 'rainbows/fiber/coolio'
4 # A combination of the Coolio and FiberSpawn models.
6 # This concurrency model is difficult to use with existing applications,
7 # lacks third-party support, and is thus NOT recommended.
9 # This allows Ruby 1.9 Fiber-based concurrency for application
10 # processing while exposing a synchronous execution model and using
11 # scalable network concurrency provided by Cool.io.  A streaming
12 # "rack.input" is exposed.  Applications are strongly advised to wrap
13 # all slow IO objects (sockets, pipes) using the Rainbows::Fiber::IO or
14 # a Cool.io-compatible class whenever possible.
15 module Rainbows::CoolioFiberSpawn
17   include Rainbows::Base
18   include Rainbows::Fiber::Coolio
20   def worker_loop(worker) # :nodoc:
21     Rainbows::Response.setup
22     init_worker_process(worker)
23     Server.const_set(:MAX, @worker_connections)
24     Rainbows::Fiber::Base.setup(Server, nil)
25     Server.const_set(:APP, Rainbows.server.app)
26     Heartbeat.new(1, true).attach(Coolio::Loop.default)
27     LISTENERS.map! { |s| Server.new(s).attach(Coolio::Loop.default) }
28     Rainbows::Client.__send__ :include, Rainbows::Fiber::Coolio::Methods
29     Coolio::Loop.default.run
30   end
31 end