On Thursday, 24 June 2021 at 18:23:01 UTC, seany wrote:
I have seen [this](https://forum.dlang.org/thread/akhbvvjgeaspmjntz...@forum.dlang.org).

I can't call break form parallel foreach.

Okey, Is there a way to easily call .stop() from such a  case?

Here is a case to consider:

    outer: foreach(i, a; parallel(array_of_a)) {
       foreach(j, b; parallel(array_of_b)) {
         auto c = myFunction0(i,j);
         auto d = myFunction1(a,b);
         auto f = myFunction2(i,b);
         auto g = myFunction3(a,j);

         if(someConditionCheck(c,d,f,g)) {
           // stop the outer foreach loop here
         }

       }
    }

Thank you

Maybe I'm wrong here, but I don't think there is any way to do that with parallel. What I would do is negate someConditionCheck and instead only do work when there is work to be done.
Obviously that may or may not be suitable.
But with parallel I don't see any way to make it happen.

Reply via email to