1 # -*- encoding: binary -*-
2 require 'rainbows/rev/thread'
6 # A combination of the Rev and ThreadSpawn models. This allows Ruby
7 # Thread-based concurrency for application processing. It DOES NOT
8 # expose a streamable "rack.input" for upload processing within the
9 # app. DevFdResponse should be used with this class to proxy
10 # asynchronous responses. All network I/O between the client and
11 # server are handled by the main thread and outside of the core
12 # application dispatch.
14 # Unlike ThreadSpawn, Rev makes this model highly suitable for
15 # slow clients and applications with medium-to-slow response times
16 # (I/O bound), but less suitable for sleepy applications.
18 # Ruby 1.8 users are strongly advised to use Rev >= 0.3.2 to get
23 class Client < Rainbows::Rev::ThreadClient
25 Thread.new(self) { |client| MASTER << [ client, app_response ] }
29 include Rainbows::Rev::Core
31 def init_worker_process(worker)
33 master = Rev::Master.new(Queue.new).attach(::Rev::Loop.default)
34 Client.const_set(:MASTER, master)