Struggling to implement parallel foreach...

Nicholas Wilson iamthewilsonator at hotmail.com
Mon Jun 17 11:55:07 UTC 2019


On Monday, 17 June 2019 at 11:38:59 UTC, Ola Fosheim Grøstad 
wrote:
>> There is also the issue that access through the (once its 
>> fixed) qualified captured context, then cannot implicitly 
>> convert to shared (as oppose to const since everything will 
>> implicitly convert to const). This will be alleviated under 
>> the new shared.
>
> Thanks for the explanation. So my understanding is that this 
> will all be fixed when the semantics of "shared" has been 
> finally decided on?

The qualified context thing should be fixed ASAP (unfortunately 
the compiler rabbit hole is rather deep...), since it is 
objectively broken, not just with shared, but const and immutable 
as well.

The nicely capturing unshared locals as shared within the local 
function will indeed have to wait until shared is respecified. 
The way I think it will go is to add a `-preview=shared` and put 
the changes behind that. Probably starting with disabling read 
and write access to shared variables without casting as this was 
pretty much universally agreed upon at dconf as a necessary, if 
not sufficient, condition for thread safety.

Manu (and maybe others) will then evaluate the model and see what 
breaks or is missing and then we repeat the design cycle.

There is also a (eventually series of) dlang.org PRs to define a 
memory model which will define more of the semantics of shared 
and multithreading.


More information about the Digitalmars-d mailing list