Permalink
Browse files

use a thread local rather than a queue so events are in the right order

  • Loading branch information...
1 parent 8938e55 commit 7a4f67a3578be3f2c3d8750488d3fe759c1b174b @tenderlove tenderlove committed Oct 30, 2013
Showing with 4 additions and 7 deletions.
  1. +4 −7 activesupport/lib/active_support/notifications/fanout.rb
@@ -107,21 +107,18 @@ def matches?(subscriber_or_name)
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

0 comments on commit 7a4f67a

Please sign in to comment.