diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-24 19:35:01 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-28 12:50:09 -0800 |
commit | ddf681ce1d3e71aef913dd7f94c60b7622523f8b (patch) | |
tree | 68e318096f625119997eab90f1977744f7f4d57c /activesupport/lib/active_support | |
parent | 6f7fc5824f2033c0f674b002dbee7f1c3f3384ac (diff) | |
download | rails-ddf681ce1d3e71aef913dd7f94c60b7622523f8b.tar.gz rails-ddf681ce1d3e71aef913dd7f94c60b7622523f8b.tar.bz2 rails-ddf681ce1d3e71aef913dd7f94c60b7622523f8b.zip |
Expose a simple Queue#wait to block until all notifications are drained
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/notifications.rb | 9 |
1 files changed, 7 insertions, 2 deletions
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 |