]> git.cworth.org Git - sup/blobdiff - lib/sup/suicide.rb
giving a block to PollManager#each_message_in_source is now optional
[sup] / lib / sup / suicide.rb
index 5085c163c1f4f5a5005b6a87ae747d9afcd4626a..98b43462eea250aa6969221d0a8456b9697bd54a 100644 (file)
@@ -8,14 +8,15 @@ class SuicideManager
   def initialize fn
     @fn = fn
     @die = false
+    @thread = nil
     self.class.i_am_the_instance self
     FileUtils.rm_f @fn
   end
 
   bool_reader :die
 
-  def start_thread
-    Redwood::reporting_thread do
+  def start
+    @thread = Redwood::reporting_thread("suicide watch") do
       while true
         sleep DELAY
         if File.exists? @fn
@@ -25,6 +26,11 @@ class SuicideManager
       end
     end
   end
+
+  def stop
+    @thread.kill if @thread
+    @thread = nil
+  end
 end
 
 end