Very limited shared promotion
aliak
something at something.com
Mon Jun 24 11:38:29 UTC 2019
On Monday, 24 June 2019 at 02:55:39 UTC, Walter Bright wrote:
> On 6/23/2019 7:42 PM, Timon Gehr wrote:
>> I really don't understand this "before" without memory
>> barriers. Without memory barriers, there is no "before". How
>> to formalize this? What is it exactly that "scope" guarantees?
>
> The reference to shared i does not extend past the end of the
> function call. That doesn't mean the cached value of i is
> propagated to all other threads.
>
> 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?
More information about the Digitalmars-d
mailing list