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

Reply via email to