diff options
author | Eric Wong <e@80x24.org> | 2015-11-14 02:47:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-11-18 02:20:25 +0000 |
commit | 70c976bdd85bb8515fea01d6ad6074ef472fc2e0 (patch) | |
tree | 51230dc24bb183176b932e0d38e181869b5485e7 /lib/rainbows/event_machine | |
parent | 9c9e3949b2ef2f299ff1590d23aa4d053b60a2fd (diff) | |
download | rainbows-70c976bdd85bb8515fea01d6ad6074ef472fc2e0.tar.gz |
Unicorn 5 removes some constants we were using, and constant lookups + inline caching are waste of time anyways on newer Rubies with the opt_str_freeze bytecode instruction. This may reduce performance for folks on older Rubies (probably not noticeable); but improves performance for folks on newer Rubies.
Diffstat (limited to 'lib/rainbows/event_machine')
-rw-r--r-- | lib/rainbows/event_machine/client.rb | 12 | ||||
-rw-r--r-- | lib/rainbows/event_machine/try_defer.rb | 5 |
2 files changed, 7 insertions, 10 deletions
diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb index 9871c09..7fb88f6 100644 --- a/lib/rainbows/event_machine/client.rb +++ b/lib/rainbows/event_machine/client.rb @@ -23,7 +23,7 @@ class Rainbows::EventMachine::Client < EM::Connection end EM.next_tick { receive_data(nil) } unless @buf.empty? else - on_read(data || Z) if (@buf.size > 0) || data + on_read(data || ''.freeze) if (@buf.size > 0) || data end end @@ -34,10 +34,10 @@ class Rainbows::EventMachine::Client < EM::Connection def app_call input set_comm_inactivity_timeout 0 - @env[RACK_INPUT] = input - @env[REMOTE_ADDR] = @_io.kgio_addr - @env[ASYNC_CALLBACK] = method(:write_async_response) - @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new + @env['rack.input'] = input + @env['REMOTE_ADDR'] = @_io.kgio_addr + @env['async.callback'] = method(:write_async_response) + @env['async.close'] = EM::DefaultDeferrable.new @hp.hijack_setup(@env, @_io) status, headers, body = catch(:async) { APP.call(@env.merge!(RACK_DEFAULTS)) @@ -117,7 +117,7 @@ class Rainbows::EventMachine::Client < EM::Connection def unbind return if @hp.hijacked? - async_close = @env[ASYNC_CLOSE] and async_close.succeed + async_close = @env['async.close'] and async_close.succeed @deferred.respond_to?(:fail) and @deferred.fail begin @_io.close diff --git a/lib/rainbows/event_machine/try_defer.rb b/lib/rainbows/event_machine/try_defer.rb index 615adae..778f3d0 100644 --- a/lib/rainbows/event_machine/try_defer.rb +++ b/lib/rainbows/event_machine/try_defer.rb @@ -10,9 +10,6 @@ # See http://brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin # for more information. class Rainbows::EventMachine::TryDefer - # shortcuts - ASYNC_CALLBACK = Rainbows::EvCore::ASYNC_CALLBACK # :nodoc: - def initialize(app) # :nodoc: # the entire app becomes multithreaded, even the root (non-deferred) # thread since any thread can share processes with others @@ -22,7 +19,7 @@ class Rainbows::EventMachine::TryDefer def call(env) # :nodoc: if @app.deferred?(env) - EM.defer(proc { catch(:async) { @app.call(env) } }, env[ASYNC_CALLBACK]) + EM.defer(proc { catch(:async) { @app.call(env) } }, env['async.callback']) # all of the async/deferred stuff breaks Rack::Lint :< nil else |