Sha256: e69af75da8dca1b7f65058f8304c701acba0d03fefaa3ed8b54de5d0514a5e9e
Contents?: true
Size: 486 Bytes
Versions: 46
Compression:
Stored size: 486 Bytes
Contents
require 'thread' module BooticCli class WorkerPool def initialize(how_many) @how_many = how_many @queue = Queue.new end def schedule(&block) @queue.push block end def start threads = @how_many.times.map do |i| Thread.new do begin while job = @queue.pop(true) job.call end rescue ThreadError end end end threads.map(&:join) end end end
Version data entries
46 entries across 46 versions & 1 rubygems