grosser / parallel

Ruby: parallel processing made simple and fast
MIT License
4.16k stars 254 forks source link

ractors #317

Closed grosser closed 2 years ago

grosser commented 2 years ago

see gotchas from https://github.com/grosser/parallel/issues/298

enumag commented 2 years ago

Hello, is there some documentation for the ractors feature? In readme you have just this:

results = Parallel.map(['a','b','c'], in_ractors: 3, ractor: [SomeClass, :expensive_calculation])

Which is a bit confusing:

grosser commented 2 years ago
enumag commented 2 years ago

Is there a way to pass some additional parameters to the ractor? When I use the Parallel.map call the SomeClass, :expensive_calculation method will receive one of the items from the array as parameter. But of course I need to pass some other values (same for all ractors). How can I do that?

grosser commented 2 years ago
actual = [1,2,3]
input = actual.map { |x| [x, ARGV, $whatever] }
Parallel.map input, ...

if it still complains then wrap the object in Ractor.make_shareable

enumag commented 2 years ago

Not very nice API in my opinion but should do the job. Thanks!

grosser commented 2 years ago

yeah, best I could do, complain to the Ractor implementors :D