Why do "const inout" and "const inout shared" exist?
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jul 2 06:56:08 PDT 2017
On 02.07.2017 15:48, Andrei Alexandrescu wrote:
> On 07/02/2017 09:39 AM, Timon Gehr wrote:
>> In general, depending on the hardware memory model and the language
>> memory model, data transfer from one thread to another requires
>> cooperation from both parties. We don't want the thread that has the
>> unshared data to need to participate in such a cooperation.
>
> Yes, there must be a handshake. Oh, I see your point. Let me illustrate:
>
> void fun(const shared int* p1)
> {
> auto a = atomicLoad(p1);
> ...
> }
>
> void gun()
> {
> int* p = new int;
> shared const int* p1 = p; // assume this passes
> spawn(&fun, p);
> *p = 42; // should be a shared write, it's not
> }
>
> Is this what you're referring to?
> ...
Yes, precisely.
> So it seems like the hierarchy in http://erdani.com/conversions.svg is
> minimal?
>
Yes, I think there is no way to collapse it without bad consequences.
More information about the Digitalmars-d
mailing list