Sha256: c72915c40f00fafd2541aef4947e3a50ea91b4e8e3c8a0422ebda1f6e042c709

Contents?: true

Size: 520 Bytes

Versions: 2

Compression:

Stored size: 520 Bytes

Contents

module Sideband
  class Thread

    attr_reader :thread

    def initialize(manager)
      @manager = manager
      @thread = ::Thread.new do
        while work = @manager.queue.pop
          exit if work.nil?
          
          begin
            work.call
          rescue Exception
            # Sideband will ignore all Exceptions, 
            # better to handle in your workers.
          end
        end
      end
    end

    def join
      thread.join
    end

    def kill
      thread.kill
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sideband-1.0.1 lib/sideband/thread.rb
sideband-1.0.0 lib/sideband/thread.rb