From b37fa6ad928fb2b5dc55126c5ad4caa55ee3193b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 26 May 2010 21:32:13 +0000 Subject: writer_thread_pool: remove single thread optimization It's not worth the trouble and testability since having a single thread tends to bottleneck if there's a bad client. --- lib/rainbows/writer_thread_pool.rb | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'lib/rainbows/writer_thread_pool.rb') diff --git a/lib/rainbows/writer_thread_pool.rb b/lib/rainbows/writer_thread_pool.rb index f881187..993e9b8 100644 --- a/lib/rainbows/writer_thread_pool.rb +++ b/lib/rainbows/writer_thread_pool.rb @@ -60,6 +60,11 @@ module Rainbows @@nr = 0 @@q = nil + def process_client(client) + @@nr += 1 + super(QueueSocket[client, @@q[@@nr %= @@q.size]]) + end + def worker_loop(worker) # we have multiple, single-thread queues since we don't want to # interleave writes from the same client @@ -79,25 +84,7 @@ module Rainbows end end - if qp.size == 1 - # avoid unnecessary calculations when there's only one queue, - # most users should only need one queue... - WriterThreadPool.module_eval do - def process_client(client) - super(QueueSocket[client, @@q]) - end - end - @@q = qp.first.queue - else - WriterThreadPool.module_eval do - def process_client(client) - @@nr += 1 - super(QueueSocket[client, @@q[@@nr %= @@q.size]]) - end - end - @@q = qp.map { |q| q.queue } - end - + @@q = qp.map { |q| q.queue } super(worker) # accept loop from Unicorn qp.map { |q| q.quit! } end -- cgit v1.2.3-24-ge0c7