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) # :nodoc:
17 init_worker_process(worker)
18 Fiber::Base.setup(self.class, app)
19 limit = worker_connections
23 break if G.cur >= limit
24 io = l.kgio_tryaccept or next
25 ::Fiber.new { process(io) }.resume
29 end while G.alive || G.cur > 0