require 'connection_pool'
module React
module Sinatra
module Runtime
@mutex ||= Mutex.new
@runtimes ||= {}
def self.[](name)
name = name.to_s
@runtimes.fetch(name) do
@mutex.synchronize do
error = try_require "react/sinatra/runtime/#{name}"
@runtimes.fetch(name) do
fail ArgumentError,
"unsupported runtime %p #{ " (#{error.message})" if error }" % name
end
end
end
end
def self.try_require(path)
require(path)
nil
rescue LoadError => error
raise(error) unless error.path == path
error
end
def self.register(name, type)
@runtimes[name.to_s] = type
end
end
end
end