1 # -*- encoding: binary -*-
2 # A combination of the Coolio and ThreadSpawn models. This allows Ruby
3 # Thread-based concurrency for application processing. It DOES NOT
4 # expose a streamable "rack.input" for upload processing within the
5 # app. DevFdResponse should be used with this class to proxy
6 # asynchronous responses. All network I/O between the client and
7 # server are handled by the main thread and outside of the core
8 # application dispatch.
10 # Unlike ThreadSpawn, Cool.io makes this model highly suitable for
11 # slow clients and applications with medium-to-slow response times
12 # (I/O bound), but less suitable for sleepy applications.
14 # This concurrency model is designed for Ruby 1.9, and Ruby 1.8
15 # users are NOT advised to use this due to high CPU usage.
17 # === RubyGem Requirements
18 # * cool.io 1.0.0 or later
19 module Rainbows::CoolioThreadSpawn
20 include Rainbows::Coolio::Core
21 autoload :Client, 'rainbows/coolio_thread_spawn/client'
23 def init_worker_process(worker) # :nodoc:
25 master = Rainbows::Coolio::Master.new(Queue.new)
26 master.attach(Coolio::Loop.default)
27 Client.const_set(:MASTER, master)