module Enumerable
Public Instance Methods
with_multithread(thread_num) { |pop| ... }
click to toggle source
# File lib/sitemap_gen/xml_crawler.rb, line 2 def with_multithread(thread_num) queue = Queue.new threads = (1..thread_num).map do Thread.new do until queue.empty? begin yield(queue.pop) rescue Exception nil end end end end each { |v| queue << v } threads.each { |t| t.join } end