Very limited shared promotion

Walter Bright newshound2 at digitalmars.com
Sat Jun 22 03:03:38 UTC 2019



1. `scope` requires that the reference to `x` passed to fun() does not persist 
past the return of fun(). If fun() is @trusted, fun() can do anything it likes, 
including passing the reference to other threads, as long as fun() does some 
sort of synchronization to ensure the other threads no longer hold that 
reference past the return of fun().

2. `scope` does not require memory cache coherency happen upon exit from fun(). 
Therefore, a non-atomic read of `x` after fun() exits is not guaranteed to have 
the latest value of `x`.

---

A corollary:

1. D has no `@safe` mechanism to convert shared references back to thread local. 
In particular, `scope` isn't it.


More information about the Digitalmars-d mailing list