diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 10:33:27 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 10:33:36 -0700 |
commit | 45318e4010e4f6303ef740bf159d2803c28acc7a (patch) | |
tree | 5be862f394592543590867742f926dce336ee1f7 /activesupport | |
parent | ea296fcc2bcc5ca087939d28018fc24ae6772f5e (diff) | |
download | rails-45318e4010e4f6303ef740bf159d2803c28acc7a.tar.gz rails-45318e4010e4f6303ef740bf159d2803c28acc7a.tar.bz2 rails-45318e4010e4f6303ef740bf159d2803c28acc7a.zip |
use a thread local rather than a queue so events are in the right order
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/notifications/fanout.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index f7f1987380..8f5fa646e8 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -107,21 +107,18 @@ module ActiveSupport end class Timed < Evented - def initialize(pattern, delegate) - @timestack = Queue.new - super - end - def publish(name, *args) @delegate.call name, *args end def start(name, id, payload) - @timestack.push Time.now + timestack = Thread.current[:_timestack] ||= [] + timestack.push Time.now end def finish(name, id, payload) - started = @timestack.pop + timestack = Thread.current[:_timestack] + started = timestack.pop @delegate.call(name, started, Time.now, id, payload) end end |