提交 ddf681ce 编写于 作者: J Jeremy Kemper

Expose a simple Queue#wait to block until all notifications are drained

上级 6f7fc582
......@@ -154,10 +154,15 @@ def subscribe(pattern=nil, &block)
@listeners << Listener.new(pattern, &block)
end
def drained?
@listeners.all? &:drained?
def wait
sleep 0.05 until drained?
end
private
def drained?
@listeners.all? &:drained?
end
class Listener
def initialize(pattern, &block)
@pattern = pattern
......
......@@ -201,6 +201,6 @@ def test_with_several_consumers_and_several_events
private
def drain
sleep(0.1) until ActiveSupport::Notifications.queue.drained?
ActiveSupport::Notifications.queue.wait
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册