Very limited shared promotion

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Jun 22 05:35:52 UTC 2019


On Saturday, 22 June 2019 at 03:03:38 UTC, Walter Bright wrote:
> 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`.

So you basically say that you need "x" to be typed as const when 
calling fun() if fun() transfers "x" to another thread.


Ola


More information about the Digitalmars-d mailing list