1 # -*- encoding: binary -*-
2 require 'rainbows/fiber/rev'
4 # CoolioFiberSpawn is the new version of this, use that instead.
6 # A combination of the Rev and FiberSpawn models. This allows Ruby
7 # 1.9 Fiber-based concurrency for application processing while
8 # exposing a synchronous execution model and using scalable network
9 # concurrency provided by Rev. A "rack.input" is exposed as well
10 # being Sunshowers-compatible. Applications are strongly advised to
11 # wrap all slow IO objects (sockets, pipes) using the
12 # Rainbows::Fiber::IO or a Rev-compatible class whenever possible.
13 module Rainbows::RevFiberSpawn
15 include Rainbows::Base
16 include Rainbows::Fiber::Rev
18 def worker_loop(worker) # :nodoc:
19 Rainbows::Response.setup(Server)
20 init_worker_process(worker)
21 Server.const_set(:MAX, @worker_connections)
22 Rainbows::Fiber::Base.setup(Server, nil)
23 Server.const_set(:APP, G.server.app)
24 Heartbeat.new(1, true).attach(Rev::Loop.default)
25 kato = Kato.new.attach(Rev::Loop.default)
26 Rainbows::Fiber::Rev::Methods.const_set(:KATO, kato)
27 LISTENERS.map! { |s| Server.new(s).attach(Rev::Loop.default) }