diff options
Diffstat (limited to 'lib/rainbows/rev_thread_spawn.rb')
-rw-r--r-- | lib/rainbows/rev_thread_spawn.rb | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/lib/rainbows/rev_thread_spawn.rb b/lib/rainbows/rev_thread_spawn.rb index 38771d3..94e9503 100644 --- a/lib/rainbows/rev_thread_spawn.rb +++ b/lib/rainbows/rev_thread_spawn.rb @@ -1,38 +1,27 @@ # -*- encoding: binary -*- -require 'rainbows/rev/thread_client' -module Rainbows - - # A combination of the Rev and ThreadSpawn models. This allows Ruby - # Thread-based concurrency for application processing. It DOES NOT - # expose a streamable "rack.input" for upload processing within the - # app. DevFdResponse should be used with this class to proxy - # asynchronous responses. All network I/O between the client and - # server are handled by the main thread and outside of the core - # application dispatch. - # - # Unlike ThreadSpawn, Rev makes this model highly suitable for - # slow clients and applications with medium-to-slow response times - # (I/O bound), but less suitable for sleepy applications. - # - # Ruby 1.8 users are strongly advised to use Rev >= 0.3.2 to get - # usable performance. - - module RevThreadSpawn - - class Client < Rainbows::Rev::ThreadClient # :nodoc: all - def app_dispatch - Thread.new(self) { |client| MASTER << [ client, app_response ] } - end - end - - include Rainbows::Rev::Core - - def init_worker_process(worker) # :nodoc: - super - master = Rev::Master.new(Queue.new).attach(::Rev::Loop.default) - Client.const_set(:MASTER, master) - end +# A combination of the Rev and ThreadSpawn models. This allows Ruby +# Thread-based concurrency for application processing. It DOES NOT +# expose a streamable "rack.input" for upload processing within the +# app. DevFdResponse should be used with this class to proxy +# asynchronous responses. All network I/O between the client and +# server are handled by the main thread and outside of the core +# application dispatch. +# +# Unlike ThreadSpawn, Rev makes this model highly suitable for +# slow clients and applications with medium-to-slow response times +# (I/O bound), but less suitable for sleepy applications. +# +# This concurrency model is designed for Ruby 1.9, and Ruby 1.8 +# users are NOT advised to use this due to high CPU usage. +module Rainbows::RevThreadSpawn + include Rainbows::Rev::Core + def init_worker_process(worker) # :nodoc: + super + master = Rainbows::Rev::Master.new(Queue.new).attach(Rev::Loop.default) + Rainbows::RevThreadSpawn::Client.const_set(:MASTER, master) end end +# :enddoc: +require 'rainbows/rev_thread_spawn/client' |