Closed grosser closed 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:
ractor: [SomeClass, :expensive_calculation]
? Is expensive_calculation
a method name on SomeClass
or something else?ARGV
array of the original process?in_ractors: 3
say "use as many ractors as possible for the current hardware" (such as the total amount of CPU cores)?in_ractors: Etc.nprocessors
/ Parallel.physical_processor_count
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?
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
Not very nice API in my opinion but should do the job. Thanks!
yeah, best I could do, complain to the Ractor implementors :D
see gotchas from https://github.com/grosser/parallel/issues/298