diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
commit | 25b32914b72a5f709eca773f3511cc89c2e710c2 (patch) | |
tree | 4dab9e78e4c6b49220a837b38d463328c05e2983 /lib/mauve/mauve_thread.rb | |
parent | 3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff) | |
parent | fd23821950f0562a8995735105cd31fdc6d55933 (diff) |
merge
Diffstat (limited to 'lib/mauve/mauve_thread.rb')
-rw-r--r-- | lib/mauve/mauve_thread.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/mauve/mauve_thread.rb b/lib/mauve/mauve_thread.rb index 6409f98..52c2801 100644 --- a/lib/mauve/mauve_thread.rb +++ b/lib/mauve/mauve_thread.rb @@ -5,7 +5,7 @@ module Mauve class MauveThread - attr_reader :state + attr_reader :state, :poll_every def initialize @thread = nil @@ -16,15 +16,20 @@ module Mauve @logger ||= Log4r::Logger.new(self.class.to_s) end + def poll_every=(i) + raise ArgumentError.new("poll_every must be numeric") unless i.is_a?(Numeric) + @poll_every = i + end + def run_thread(interval = 0.1) # # Good to go. # self.state = :starting - @sleep_interval ||= interval + @poll_every ||= interval - sleep_loops = (@sleep_interval.to_f / 0.1).round.to_i + sleep_loops = (@poll_every.to_f / 0.1).round.to_i sleep_loops = 1 if sleep_loops.nil? or sleep_loops < 1 while self.state != :stopping do @@ -110,9 +115,9 @@ module Mauve @thread.join if @thread.is_a?(Thread) end - def raise(ex) - @thread.raise(ex) - end +# def raise(ex) +# @thread.raise(ex) +# end def backtrace @thread.backtrace if @thread.is_a?(Thread) |