On Mon, 2018-05-28 at 21:04 +0000, Dr.No via Digitalmars-d-learn wrote:
> import std.parallelism : parallel;
> foreach(t; parallel(arr))
> {
> if(!doSomething(t)) {
> return false;
> }
> }
>
> It reuturns the run time error:
>
> > std.parallelism.ParallelForeachError@(0): Cannot break from a
> > parallel foreach loop using break, return, labeled
> > break/continue or goto statements.
>
> What's the proper way to break from loop?It isn't a loop, it is a task scatter/gather, with each task running to completion independent of all other tasks. Thus the concept of break/return doesn't exist. It could be argued that this is a bad use of foreach, but it is what it is. -- Russel. =========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part
