lib/sideband/manager.rb in sideband-1.0.2 vs lib/sideband/manager.rb in sideband-1.0.3
- old
+ new
@@ -1,19 +1,20 @@
module Sideband
class Manager
-
+
def initialize
@pid = ::Process.pid
thread!
queue!
end
-
+
def queue
handle_fork
+ handle_dead_thread
@queue
end
-
+
def thread
@thread
end
def join
@@ -25,24 +26,30 @@
@thread.kill
@thread = @queue = nil
end
private
-
+
def queue!
@queue = Sideband::Queue.new
end
-
+
def thread!
@thread.kill if @thread
@thread = Sideband::Thread.new(self)
end
-
+
def handle_fork
if ::Process.pid != @pid
@pid = ::Process.pid
thread!
queue!
+ end
+ end
+
+ def handle_dead_thread
+ if @thread && @thread.thread.alive?
+ thread!
end
end
end
end