Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit ddf681ce1d3e71aef913dd7f94c60b7622523f8b 1 parent 6f7fc58
@jeremy jeremy authored
View
9 activesupport/lib/active_support/notifications.rb
@@ -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
View
2  activesupport/test/notifications_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.