coolio_thread_*: lazy load Rainbows::Coolio::Client
[rainbows.git] / lib / rainbows / coolio_thread_spawn.rb
bloba26c9709088d28d07a911ed27d3b173d12b98443
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.
16 module Rainbows::CoolioThreadSpawn
17   include Rainbows::Coolio::Core
18   autoload :Client, 'rainbows/coolio_thread_spawn/client'
20   def init_worker_process(worker) # :nodoc:
21     super
22     master = Rainbows::Coolio::Master.new(Queue.new)
23     master.attach(Coolio::Loop.default)
24     Client.const_set(:MASTER, master)
25   end
26 end
27 # :enddoc: