10-06-2025 06:52 AM - edited 10-06-2025 06:55 AM
Does this parallel For Loop create copies of the Class or does it pass by reference?
Or asked in a different way:
Does this make any sense or do I destroy my parallelism?
Solved! Go to Solution.
10-06-2025 08:16 AM
Hi,
Image 1:
Yes, each iteration will have its own independent copy of the object.
Be careful, if the loop executes 0 time (in case your input arrays are empty), the class output tunnel will give the default value for the class (you will loose your object's private data).
Image 2:
Using a shift register will reuse the same object in place (so no copy), but it will force a sequential execution of the iterations.
We could give better advice if you explained in more details what you are trying to achieve, why the parallelism and what each input/output represents.
Regards,
Raphaël.
10-06-2025 08:33 AM - edited 10-06-2025 08:35 AM
Thank you for your answer.
After the loop I will still have the private data available that I input before the loop, I guess.
And I am definitely not changing any private data inside the loop.
But thanks for your input that the data is lost when the loop executes 0 times.
I want to read chunks of data from different ECUs via diagnostics, that takes 100-200ms. I do not want that to happen sequentially, but in parallel (each execution is one ECU). Therefore the parallel For Loop.
Input is the session data, output is the read data.
My only concern then is that if I run the whole thing in a while loop I will be creating lots and lots of object copies...
10-06-2025 08:50 AM
LVOOP always have classes by value, if you want referenced based classes you'll need G# or GOOP.