class Rack::Lock
Rack::Lock locks every request inside a mutex, so that every request will effectively be executed synchronously.
Public Class Methods
new(app, mutex = Mutex.new)
click to toggle source
# File lib/rack/lock.rb, line 8 def initialize(app, mutex = Mutex.new) @app, @mutex = app, mutex end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/lock.rb, line 12 def call(env) @mutex.lock begin response = @app.call(env.merge(RACK_MULTITHREAD => false)) returned = response << BodyProxy.new(response.pop) { @mutex.unlock } ensure @mutex.unlock unless returned end end