I need to write a script that:
- Builds an input array for a function.
- When there is an available worker, assign execution of the function to the worker. Then build the input array for the next worker. If no available worker, continue building a larger array for the input.
- The output is added to a result array whenever a worker finishes executing the function. When a worker finishes, it executes the function for the next input array.
- Essentially the script keeps building an input array and sends it to a worker whenever there is one available.
Building the input array is also time consuming so that is why it needs to be done in parallel with executing the function.
Can I please get a simple example on how to write this? Otherwise please let me know if there is already an example out there. Looked at using parfeval but can't seem to get it to work is I need.
Thank you very much.