Sha256: a277099cd57ee6b043c51bef80c3640c717ec767a04083a8970c33c00e7259ae

Contents?: true

Size: 321 Bytes

Versions: 2

Compression:

Stored size: 321 Bytes

Contents


def par_map(n, things, &block)
  queue = Queue.new
  things.each { |thing| queue << thing }
  threads = (1..n).collect do
    Thread.new do
      begin
        while true
          yield queue.pop(true)
        end
      rescue ThreadError

      end
    end
  end
  threads.each { |t| t.join }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ceedling-0.29.1 lib/ceedling/par_map.rb
ceedling-0.29.0 lib/ceedling/par_map.rb