Parent

Gem::Mirror::Pool

Public Class Methods

new(size) click to toggle source
# File lib/rubygems/mirror/pool.rb, line 4
def initialize(size)
  @size = size
  @queue = Queue.new
end

Public Instance Methods

job(&blk) click to toggle source
# File lib/rubygems/mirror/pool.rb, line 9
def job(&blk)
  @queue << blk
end
run_til_done() click to toggle source
# File lib/rubygems/mirror/pool.rb, line 13
def run_til_done
  threads = Array.new(@size) do
    Thread.new { @queue.pop.call while true }
  end
  until @queue.empty? && @queue.num_waiting == @size
    threads.each { |t| t.join(0.1) }
  end
  threads.each { |t| t.kill }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.