diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-04 22:16:52 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-04 22:34:09 +0000 |
commit | 39b178cdebe275cbc8ce19cf269bea7cd15ff4ca (patch) | |
tree | b7628ed278895fcf70ea3206956be586ac9e1ac5 /lib/rainbows/writer_thread_pool.rb | |
parent | 75f5aa9a0d6b37a94afbea3121fc2c16e70a2b1d (diff) | |
download | rainbows-39b178cdebe275cbc8ce19cf269bea7cd15ff4ca.tar.gz |
This hopefully allows the "sendfile" gem to be required anywhere in the Rainbows!/Unicorn config file, and not have to be required via RUBYOPT or the '-r' command-line switch. We also modularize HttpResponse and avoids singleton methods in the response path. This (hopefully) makes it easier for individual concurrency models to share code and override individual methods.
Diffstat (limited to 'lib/rainbows/writer_thread_pool.rb')
-rw-r--r-- | lib/rainbows/writer_thread_pool.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/rainbows/writer_thread_pool.rb b/lib/rainbows/writer_thread_pool.rb index f7eb2aa..b6c53e8 100644 --- a/lib/rainbows/writer_thread_pool.rb +++ b/lib/rainbows/writer_thread_pool.rb @@ -46,8 +46,10 @@ module Rainbows end end - def write_body(qclient, body) - qclient.q << [ qclient.to_io, :body, body ] + module Response + def write_body(qclient, body) + qclient.q << [ qclient.to_io, :body, body ] + end end @@nr = 0 @@ -59,6 +61,10 @@ module Rainbows end def worker_loop(worker) + Rainbows::HttpResponse.setup(self.class) + self.class.__send__(:alias_method, :sync_write_body, :write_body) + self.class.__send__(:include, Response) + # 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| @@ -66,7 +72,7 @@ module Rainbows begin io, arg1, arg2 = response case arg1 - when :body then Base.write_body(io, arg2) + when :body then sync_write_body(io, arg2) when :close then io.close unless io.closed? else io.write(arg1) |