Skip to content

Commit 45318e4

Browse files
committed
use a thread local rather than a queue so events are in the right order
1 parent ea296fc commit 45318e4

File tree

1 file changed

+4
-7
lines changed
  • activesupport/lib/active_support/notifications

1 file changed

+4
-7
lines changed

activesupport/lib/active_support/notifications/fanout.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,18 @@ def matches?(subscriber_or_name)
107107
end
108108

109109
class Timed < Evented
110-
def initialize(pattern, delegate)
111-
@timestack = Queue.new
112-
super
113-
end
114-
115110
def publish(name, *args)
116111
@delegate.call name, *args
117112
end
118113

119114
def start(name, id, payload)
120-
@timestack.push Time.now
115+
timestack = Thread.current[:_timestack] ||= []
116+
timestack.push Time.now
121117
end
122118

123119
def finish(name, id, payload)
124-
started = @timestack.pop
120+
timestack = Thread.current[:_timestack]
121+
started = timestack.pop
125122
@delegate.call(name, started, Time.now, id, payload)
126123
end
127124
end

0 commit comments

Comments
 (0)