class Rack::Lock
will effectively be executed synchronously.
Rack::Lock locks every request inside a mutex, so that every request
def call(env)
def call(env) @mutex.lock @env = env @old_rack_multithread = env[RACK_MULTITHREAD] begin response = @app.call(env.merge!(RACK_MULTITHREAD => false)) returned = response << BodyProxy.new(response.pop) { unlock } ensure unlock unless returned end end
def initialize(app, mutex = Mutex.new)
def initialize(app, mutex = Mutex.new) @app, @mutex = app, mutex end
def unlock
def unlock @mutex.unlock @env[RACK_MULTITHREAD] = @old_rack_multithread end