Robert Klemme wrote:
> processes = 4
> count = 0
> 
> my_array.each do |task|
>    if count == processes
>      Process.wait
>      count -= 1
>    end
> 
>    fork do
>      a_method(task)
>    end
>    count += 1
> end
> 
> Process.waitall

Another option,

Tiamat.open_local(4) {
  pure do
    fun_map :result => my_array do |elem|
      a_method(elem)
    end
  end.compute.result
}

This lets you distribute across N physical machines without a change to 
the code.
-- 
Posted via http://www.ruby-forum.com/.