aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/lib/action_dispatch/vendor/rack-1.1.pre/rack/lock.rb
blob: 93238528c44ac70bde6984c7bf473ea3b4a9ca73 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                          
module Rack
  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