aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/mauve_thread.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-18 16:44:21 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-18 16:44:21 +0100
commitbbc6dc3fccfcdffef65211dd4d1c4058ecef624b (patch)
treebb99c37166e130ca393121cdfae8cb19f6f472ba /lib/mauve/mauve_thread.rb
parentd84d5fb931850955a9eb0f4a0edd0b6a00dc8ed9 (diff)
Improved code to avoid Exception when the processor attempts to freeze a thread
that is not running.
Diffstat (limited to 'lib/mauve/mauve_thread.rb')
-rw-r--r--lib/mauve/mauve_thread.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/mauve/mauve_thread.rb b/lib/mauve/mauve_thread.rb
index 4a2787d..55ec446 100644
--- a/lib/mauve/mauve_thread.rb
+++ b/lib/mauve/mauve_thread.rb
@@ -7,6 +7,7 @@ module Mauve
def initialize
@thread = nil
+ @stop = true
end
def logger
@@ -53,15 +54,13 @@ module Mauve
@frozen = true
- if @thread.is_a?(Thread)
- 20.times { Kernel.sleep 0.1 ; break if @thread.stop? }
+ 20.times { Kernel.sleep 0.1 ; break if @thread.stop? }
- logger.debug("Thread has not frozen!") unless @thread.stop?
- end
+ logger.debug("Thread has not frozen!") unless @thread.stop?
end
def frozen?
- defined? @frozen and @frozen and @thread.is_a?(Thread) and @thread.stop?
+ self.alive? and self.stop?
end
def thaw
@@ -90,7 +89,7 @@ module Mauve
end
def stop?
- @thread.is_a?(Thread) and @thread.stop?
+ !@thread.is_a?(Thread) or @thread.stop?
end
def join(ok_exceptions=[])
@@ -128,7 +127,6 @@ module Mauve
self.join
end
-
alias exit stop
def kill