diff options
-rw-r--r-- | lib/rainbows/writer_thread_pool.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/rainbows/writer_thread_pool.rb b/lib/rainbows/writer_thread_pool.rb index dd3dd7c..c4d8d9f 100644 --- a/lib/rainbows/writer_thread_pool.rb +++ b/lib/rainbows/writer_thread_pool.rb @@ -46,25 +46,25 @@ module Rainbows end end - module Response # :nodoc: - def write_body(qclient, body, range) - qclient.q << [ qclient.to_io, :body, body, range ] - end - end - @@nr = 0 @@q = nil + def async_write_body(qclient, body, range) + qclient.q << [ qclient.to_io, :body, body, range ] + end + def process_client(client) # :nodoc: @@nr += 1 - super(QueueSocket[client, @@q[@@nr %= @@q.size]]) + super(QueueSocket.new(client, @@q[@@nr %= @@q.size])) end - def worker_loop(worker) # :nodoc: - Rainbows::Response.setup(self.class) + def init_worker_process(worker) + super self.class.__send__(:alias_method, :sync_write_body, :write_body) - self.class.__send__(:include, Response) + WriterThreadPool.__send__(:alias_method, :write_body, :async_write_body) + end + def worker_loop(worker) # :nodoc: # we have multiple, single-thread queues since we don't want to # interleave writes from the same client qp = (1..worker_connections).map do |n| |