diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-06-17 12:48:53 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-06-17 12:48:53 +0100 |
commit | a2fc458d4c1bc6027760546653cb153e775576ce (patch) | |
tree | f3af3775adab48d9a18495eeb410cf48269ffd9e /lib/mauve/notifier.rb | |
parent | 4b39583e63b59d73e2855d776f7cca12d734f2af (diff) |
* Notifications are now run in their separate threads.
* Queues are now just arrays instead of "Queue"s
* Updated templates to be saner.
* Added flusing of queues when threads stop
Diffstat (limited to 'lib/mauve/notifier.rb')
-rw-r--r-- | lib/mauve/notifier.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb index 5c0e5a7..90df895 100644 --- a/lib/mauve/notifier.rb +++ b/lib/mauve/notifier.rb @@ -25,12 +25,24 @@ module Mauve logger.debug("Notifier buffer is #{sz} in length") - (sz > 50 ? 50 : sz).times do - person, level, alert = Server.notification_pop + my_threads = [] + sz.times do + person, *args = Server.notification_pop + + # + # Nil person.. that's craaazy too! + # + break if person.nil? + my_threads << Thread.new { + person.do_send_alert(*args) + } + end + + my_threads.each do |t| begin - person.do_send_alert(level, alert) + t.join rescue StandardError => ex - logger.debug ex.to_s + logger.error ex.to_s logger.debug ex.backtrace.join("\n") end end @@ -73,6 +85,11 @@ module Mauve end super + + # + # flush the queue + # + main_loop end end |