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