Yet another parallel foreach + continue question
Steven Schveighoffer
schveiguy at gmail.com
Wed Jul 21 13:49:25 UTC 2021
On 7/19/21 10:58 PM, H. S. Teoh wrote:
> I didn't check the implementation to verify this, but I'm pretty sure
> `break`, `continue`, etc., in the parallel foreach body does not change
> which iteration gets run or not.
`break` should be undefined behavior (it is impossible to know which
loops have already executed by that point). `continue` should be fine.
Noted in the
[docs](https://dlang.org/phobos/std_parallelism.html#.TaskPool.parallel):
Breaking from a parallel foreach loop via a break, labeled break,
labeled continue, return or goto statement throws a ParallelForeachError.
I would say `continue` is ok (probably just implemented as an early
return), but all those others are going to throw an error (unrecoverable).
-Steve
More information about the Digitalmars-d-learn
mailing list