Very limited shared promotion

XavierAP n3minis-git at yahoo.es
Mon Jun 24 11:55:25 UTC 2019


On Monday, 24 June 2019 at 11:38:29 UTC, aliak wrote:
> On Monday, 24 June 2019 at 02:55:39 UTC, Walter Bright wrote:
>>
>>     int x;
>>     void fun(scope ref shared(int) x) {
>>         x = 3; // (*)
>>     } // end of reference to x is guaranteed
>>     assert(x == 3); // all caches not updated, assert is not 
>> guaranteed
>>
>> (*) now replace this with a call to another thread to set x to 
>> 3.
>
> You can assign to a shared primitive without a compilation 
> error?
>
> Does the compiler do the necessary synchronization under the 
> hood?
>
> I would've assumed you'd have to use atomicStore or the like?

(*) now replace this with a call to another thread to set x to 3.


More information about the Digitalmars-d mailing list