Yet another parallel foreach + continue question

seany seany at uni-bonn.de
Tue Jul 20 00:07:10 UTC 2021


Consider :

     for (int i = 0; i < max_value_of_i; i++) {
         foreach ( j, dummyVar; 
myTaskPool.parallel(array_to_get_j_from, my_workunitSize) {

             if ( boolean_function(i,j) ) continue;
             double d = expensiveFunction(i,j);
             // ... stuff ...
         }
     }

I understand, that the parallel iterator will pick lazily values 
of `j` (up to `my_workunitsize`), and execute the for loop for 
those values in its own thread.

Say, values of `j` from `10`to `20` is filled where 
`my_workunitsize` = 11. Say, at `j = 13` the `boolean_function` 
returns true.

Will then the for loop just jump to the next value of `j = 14`  
like a normal for loop? I am having a bit of difficulty to 
understand this. Thank you.




More information about the Digitalmars-d-learn mailing list