Acess variable that was set by thread

bauss jacobbauss at gmail.com
Mon Aug 8 17:45:03 UTC 2022


On Monday, 8 August 2022 at 13:55:02 UTC, ag0aep6g wrote:
>         auto x = s.x;
> ```
>

Your problem is here and not because it was __gshared.

You're copying the value and obviously it can be changed in the 
meantime, that's common sense.

You shouldn't use it like that. You should access s.x directly 
instead.

And in the case of shared it can leave the same result if the 
reading thread locks first then it will read and process the 
value before it's changed.




More information about the Digitalmars-d-learn mailing list