mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
thread safety
This commit is contained in:
parent
449c85918f
commit
7b1a65b347
1 changed files with 13 additions and 1 deletions
|
@ -90,7 +90,15 @@ module Sinatra
|
|||
klass.extend ExtensionMethods
|
||||
klass.enable :reload_templates
|
||||
klass.set(:reloader) { klass.development? }
|
||||
klass.before { Reloader.perform(klass) if klass.reloader? }
|
||||
klass.before do
|
||||
if klass.reloader?
|
||||
if Reloader.thread_safe?
|
||||
Thread.exclusive { Reloader.perform(klass) }
|
||||
else
|
||||
Reloader.perform(klass)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.perform(klass)
|
||||
|
@ -105,6 +113,10 @@ module Sinatra
|
|||
end
|
||||
end
|
||||
|
||||
def self.thread_safe?
|
||||
Thread and Thread.list.size > 1 and Thread.respond_to?(:exclusive)
|
||||
end
|
||||
|
||||
module BaseMethods
|
||||
def route(verb, path, options={}, &block)
|
||||
source_location = block.respond_to?(:source_location) ?
|
||||
|
|
Loading…
Reference in a new issue