From 8c8e5ae926e0009743fe92dccb588783640a6022 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Wed, 17 Aug 2011 11:08:07 +0100 Subject: * 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 --- lib/mauve/mauve_thread.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/mauve/mauve_thread.rb') 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? -- cgit v1.2.1