Sha256: 03e0a9a9b6af0e5a267c9a7e1d77adc6e1695b1997de18faf1cad5db7d3d7dbd

Contents?: true

Size: 659 Bytes

Versions: 3

Compression:

Stored size: 659 Bytes

Contents

module Sideband
  class Manager
    
    def initialize
      @pid = ::Process.pid
      thread!
      queue!
    end
  
    def queue
      handle_fork
      @queue
    end
  
    def thread
      @thread
    end

    def join
      @queue.kill
      @thread.join
    end

    def kill
      @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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sideband-1.0.2 lib/sideband/manager.rb
sideband-1.0.1 lib/sideband/manager.rb
sideband-1.0.0 lib/sideband/manager.rb