How to call stop from parallel foreach
seany
seany at uni-bonn.de
Thu Jun 24 20:14:42 UTC 2021
On Thursday, 24 June 2021 at 20:08:06 UTC, seany wrote:
> On Thursday, 24 June 2021 at 19:46:52 UTC, Jerry wrote:
>> On Thursday, 24 June 2021 at 18:23:01 UTC, seany wrote:
>>> [...]
>>
>> 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.
>
> The parallel() function is running a taskpool. I should be able
> to stop that in any case...
PS :
I have done this :
parallelContainer: while(true) {
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)) {
break parallelContainer;
}
}
break;
}
Is this safe? Will this cause any problem that I can't foresee
now? Thank you
More information about the Digitalmars-d-learn
mailing list