提交 45318e40 编写于 作者: A Aaron Patterson

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

上级 ea296fcc
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册