Class: Rack::Lock

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/lock.rb

Constant Summary collapse

FLAG =
'rack.multithread'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, lock = Mutex.new) ⇒ Lock

Returns a new instance of Lock.



5
6
7
# File 'lib/rack/lock.rb', line 5

def initialize(app, lock = Mutex.new)
  @app, @lock = app, lock
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/rack/lock.rb', line 9

def call(env)
  old, env[FLAG] = env[FLAG], false
  @lock.synchronize { @app.call(env) }
ensure
  env[FLAG] = old
end