Hello!
Is there an idiomatic way of collecting output from a set of tasks run using the Worker API? In other words, if I have a workerExecutor fire off a Runnable task to a bunch of workers to operate on files in parallel, what’s the best way to ‘collect’ the output of the calculation?
To give a more concrete example, say we re-use the Worker API tutorial example that computes a hash per file, if instead of writing the hash to a file in each Runnable, you wanted to simply return the hash string, then have the initial task collect them all and dump them to a single file?
I’ve found a way using a ConcurrentHashMap as a static variable on the task, and having the Runnable update that, but it’s a bit hacky, and prevents the tasks from safely being re-used in parallel. I’ve tried passing the Map as an argument to the runnable via params, but it appears to copy the object, not pass the reference to it, hence each Runnable gets its own copy
Thoughts?