提交 644a1796 编写于 作者: A Aaron Patterson

remove global cache

上级 e4de78ae
...@@ -135,8 +135,6 @@ module ActiveSupport ...@@ -135,8 +135,6 @@ module ActiveSupport
# to log subscribers in a thread. You can use any queue implementation you want. # to log subscribers in a thread. You can use any queue implementation you want.
# #
module Notifications module Notifications
@instrumenters = Hash.new { |h,k| h[k] = notifier.listening?(k) }
class Registry # :nodoc: class Registry # :nodoc:
def self.instance def self.instance
Thread.current[name] ||= new Thread.current[name] ||= new
...@@ -160,7 +158,7 @@ def publish(name, *args) ...@@ -160,7 +158,7 @@ def publish(name, *args)
end end
def instrument(name, payload = {}) def instrument(name, payload = {})
if @instrumenters[name] if notifier.listening?(name)
instrumenter.instrument(name, payload) { yield payload if block_given? } instrumenter.instrument(name, payload) { yield payload if block_given? }
else else
yield payload if block_given? yield payload if block_given?
...@@ -168,9 +166,7 @@ def instrument(name, payload = {}) ...@@ -168,9 +166,7 @@ def instrument(name, payload = {})
end end
def subscribe(*args, &block) def subscribe(*args, &block)
notifier.subscribe(*args, &block).tap do notifier.subscribe(*args, &block)
@instrumenters.clear
end
end end
def subscribed(callback, *args, &block) def subscribed(callback, *args, &block)
...@@ -182,7 +178,6 @@ def subscribed(callback, *args, &block) ...@@ -182,7 +178,6 @@ def subscribed(callback, *args, &block)
def unsubscribe(args) def unsubscribe(args)
notifier.unsubscribe(args) notifier.unsubscribe(args)
@instrumenters.clear
end end
def instrumenter def instrumenter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册