Partition a loop to be processed on different cores parallel

127 Views Asked by At

How can I accomplish a loop that will que it's iterations on the available CPU cores? So each iteration will be run in parallel and therefore finish faster? I'm trying to understand the gem Celluloid but if there is another gem that I could use don't hesitate to tell me!

1

There are 1 best solutions below

0
Chris Mowforth On

If it weren't for the jRuby tag I'd be inclined to mark as a duplicate too ;)

You don't state exactly what problem you're trying to solve but since your Ruby now has access to the Java standard lib, in Java 7+ you could use the Fork/Join framework. Charles Nutter has written a nice JRuby wrapper.