1 # -*- encoding: binary -*-
2 require 'rainbows/fiber'
6 # Simple Fiber-based concurrency model for 1.9. This spawns a new
7 # Fiber for every incoming client connection and the root Fiber for
8 # scheduling and connection acceptance. This exports a streaming
9 # "rack.input" with lightweight concurrency. Applications are
10 # strongly advised to wrap all slow IO objects (sockets, pipes) using
11 # the Rainbows::Fiber::IO class whenever possible.
16 def worker_loop(worker)
17 init_worker_process(worker)
18 Fiber::Base.const_set(:APP, app)
19 limit = worker_connections
20 fio = Rainbows::Fiber::IO
24 break if G.cur >= limit
25 io = Rainbows.accept(l) or next
26 ::Fiber.new { process_client(fio.new(io, ::Fiber.current)) }.resume
30 end while G.alive || G.cur > 0