diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-26 22:48:33 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-26 22:48:33 +0000 |
commit | a50c9d312b9d5274a95f2816b5f53a3738d0cb92 (patch) | |
tree | 266b30d91cd45a19c1867e3f8f774d355302e6cc /lib/rainbows/rev_thread_spawn.rb | |
parent | 6741aa27e4c35724b5306644d3a391fce415b0c7 (diff) | |
download | rainbows-a50c9d312b9d5274a95f2816b5f53a3738d0cb92.tar.gz |
This should make classes easier to find and hopefully make our code easier to follow.
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' |