1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

thread safety

This commit is contained in:
Gabriel Andretta 2011-04-13 21:45:39 -03:00
parent 449c85918f
commit 7b1a65b347

View file

@ -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) ?