diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-01-27 18:54:01 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-01-27 18:54:01 -0600 |
commit | 319ae4628f4e0058de3e40e4ca7791b17e45e70c (patch) | |
tree | e5da1bfe6dd69a9cf483c9ff9fd18c5bfdd2f463 /actionpack/lib/action_dispatch/rack/lock.rb | |
parent | a0f2b1d95d3785de92ae271fd7ea23e91c0cadc6 (diff) | |
download | rails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.tar.gz rails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.tar.bz2 rails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.zip |
Move HTTP libs and middleware into ActionDispatch component
Diffstat (limited to 'actionpack/lib/action_dispatch/rack/lock.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/rack/lock.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/rack/lock.rb b/actionpack/lib/action_dispatch/rack/lock.rb new file mode 100644 index 0000000000..9bf1889065 --- /dev/null +++ b/actionpack/lib/action_dispatch/rack/lock.rb @@ -0,0 +1,21 @@ +module Rack + # Rack::Lock was commited to Rack core + # http://github.com/rack/rack/commit/7409b0c + # Remove this when Rack 1.0 is released + unless defined? Lock + class Lock + FLAG = 'rack.multithread'.freeze + + def initialize(app, lock = Mutex.new) + @app, @lock = app, lock + end + + def call(env) + old, env[FLAG] = env[FLAG], false + @lock.synchronize { @app.call(env) } + ensure + env[FLAG] = old + end + end + end +end |