diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-22 06:25:00 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-04-22 06:25:00 -0700 |
commit | f95b06f96faa009b7d2523c3c244ca6d8512e373 (patch) | |
tree | fb30a825a08a1e4e202dd04243c3e8118e4abae3 /activesupport | |
parent | a4299937423138caf9e0018c50649cd12d63fd32 (diff) | |
parent | be7e34bc1ef81a5c78a86be7201d3aab5106978b (diff) | |
download | rails-f95b06f96faa009b7d2523c3c244ca6d8512e373.tar.gz rails-f95b06f96faa009b7d2523c3c244ca6d8512e373.tar.bz2 rails-f95b06f96faa009b7d2523c3c244ca6d8512e373.zip |
Merge pull request #10285 from wangjohn/subscriber_registry
Created a registry for ActiveSupport::Subscriber queues
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/subscriber.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/subscriber.rb b/activesupport/lib/active_support/subscriber.rb index ab76cf5c85..34c6f900c1 100644 --- a/activesupport/lib/active_support/subscriber.rb +++ b/activesupport/lib/active_support/subscriber.rb @@ -1,3 +1,5 @@ +require 'active_support/per_thread_registry' + module ActiveSupport # ActiveSupport::Subscriber is an object set to consume # ActiveSupport::Notifications. The subscriber dispatches notifications to @@ -68,8 +70,24 @@ module ActiveSupport private - def event_stack - Thread.current[@queue_key] ||= [] + def event_stack + SubscriberQueueRegistry.get_queue(@queue_key) + end + end + + # This is a registry for all the event stacks kept for subscribers. + # + # See the documentation of <tt>ActiveSupport::PerThreadRegistry</tt> + # for further details. + class SubscriberQueueRegistry # :nodoc: + extend PerThreadRegistry + + def initialize + @registry = {} + end + + def get_queue(queue_key) + @registry[queue_key] ||= [] end end end |