lib/httpx.rb in httpx-1.1.2 vs lib/httpx.rb in httpx-1.1.3

- old
+ new

@@ -18,39 +18,40 @@ require "httpx/request" require "httpx/response" require "httpx/options" require "httpx/chainable" -require "mutex_m" # Top-Level Namespace # module HTTPX EMPTY = [].freeze # All plugins should be stored under this module/namespace. Can register and load # plugins. # module Plugins @plugins = {} - @plugins.extend(Mutex_m) + @plugins_mutex = Thread::Mutex.new # Loads a plugin based on a name. If the plugin hasn't been loaded, tries to load # it from the load path under "httpx/plugins/" directory. # def self.load_plugin(name) h = @plugins - unless (plugin = h.synchronize { h[name] }) + m = @plugins_mutex + unless (plugin = m.synchronize { h[name] }) require "httpx/plugins/#{name}" - raise "Plugin #{name} hasn't been registered" unless (plugin = h.synchronize { h[name] }) + raise "Plugin #{name} hasn't been registered" unless (plugin = m.synchronize { h[name] }) end plugin end # Registers a plugin (+mod+) in the central store indexed by +name+. # def self.register_plugin(name, mod) h = @plugins - h.synchronize { h[name] = mod } + m = @plugins_mutex + m.synchronize { h[name] = mod } end end extend Chainable end