diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-17 11:08:07 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-17 11:08:07 +0100 |
commit | 8c8e5ae926e0009743fe92dccb588783640a6022 (patch) | |
tree | e23eea583beac0caf5fb3e45a33b4d2ac7796abf /lib/mauve/mauve_thread.rb | |
parent | 79dcf16ec6d229d6c31e055ed8e6a98327526a3a (diff) |
* Reminder notifications now take the same path to notify as initial alerts
* Threading tidied -- processor will not do anything unless the timer has frozen
* Person#send_alert now tidied and merged with alert_changed
* POP3 server only shows alerts relevant to the user
* Server now defaults to using an in-memory SQLite database (good for testing)
* Server initializes a blank mauve config.
* Tests tidied up
Diffstat (limited to 'lib/mauve/mauve_thread.rb')
-rw-r--r-- | lib/mauve/mauve_thread.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/mauve/mauve_thread.rb b/lib/mauve/mauve_thread.rb index 52c2801..77df95e 100644 --- a/lib/mauve/mauve_thread.rb +++ b/lib/mauve/mauve_thread.rb @@ -18,10 +18,18 @@ module Mauve def poll_every=(i) raise ArgumentError.new("poll_every must be numeric") unless i.is_a?(Numeric) + # + # Set the minimum poll frequency. + # + if i.to_f < 0.2 + logger.debug "Increasing thread polling interval to 0.2s from #{i}" + i = 0.2 + end + @poll_every = i end - def run_thread(interval = 0.1) + def run_thread(interval = 1.0) # # Good to go. # @@ -70,18 +78,21 @@ module Mauve def state=(s) raise "Bad state for mauve_thread #{s.inspect}" unless [:stopped, :starting, :started, :freezing, :frozen, :stopping, :killing, :killed].include?(s) + unless @state == s @state = s logger.debug(s.to_s.capitalize) end + + @state end def freeze self.state = :freezing - 20.times { Kernel.sleep 0.1 ; break if @thread.stop? } + 20.times { Kernel.sleep 0.2 ; break if @thread.stop? } - logger.debug("Thread has not frozen!") unless @thread.stop? + logger.warn("Thread has not frozen!") unless @thread.stop? end def frozen? |