diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-05-26 21:32:13 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-05-26 21:36:05 +0000 |
commit | b37fa6ad928fb2b5dc55126c5ad4caa55ee3193b (patch) | |
tree | 04477598db7b36296ac8265ceb561520cf4cb7c1 /lib | |
parent | f741974675c066b245e781c0c248b1395188334b (diff) | |
download | rainbows-b37fa6ad928fb2b5dc55126c5ad4caa55ee3193b.tar.gz |
It's not worth the trouble and testability since having a single thread tends to bottleneck if there's a bad client.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rainbows/writer_thread_pool.rb | 25 |
1 files changed, 6 insertions, 19 deletions
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 |