Skip to content

wrong number of parallel threads when number of elements is relatively small compared to degree of parallelism #7

@awalland

Description

@awalland

hi!

thanks a lot for peach, i think it's a great way to parallelize things, but there's a bug when the number of elements to be looped is less than 2*threads:

#!/usr/bin/env ruby

require 'peach'


@max_threads=10
@elements=19

exports = Array.new
puts "start"


$i = 0;
$num = @elements;

while $i < $num  do
    exports.push($i)
   $i +=1;
end

puts "array initialized"

def do_export(num)
    print " |export #{num} "
    %x(sleep 5)
end

puts "max_threads: #{@max_threads}"

exports.peach(@max_threads) do |export|
    do_export(export)
end

this code will execute 19 threads instead of 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions