From ddf681ce1d3e71aef913dd7f94c60b7622523f8b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 24 Nov 2009 19:35:01 -0800 Subject: Expose a simple Queue#wait to block until all notifications are drained --- activesupport/lib/active_support/notifications.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/notifications.rb') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 7a9f76b26a..09b1aa1713 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -154,10 +154,15 @@ module ActiveSupport @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 -- cgit v1.2.3