Acess variable that was set by thread

bauss jacobbauss at gmail.com
Mon Aug 8 12:45:20 UTC 2022


On Monday, 8 August 2022 at 10:17:57 UTC, ag0aep6g wrote:
>
> Never ever use `__gshared` ever.

I don't agree with this entirely, it just depends on how you use 
it. In general you should go with shared, but __gshared does have 
its places. It's only problematic when it can be changed from 
multiple threads, but if it's only changed from a single thread 
but read from many then it generally isn't a problem.

To sum it up:

Single-write/Single-read?
__gshared

Single-write/Multi-read?
__gshared

Multi-write/Single-read?
shared

Multi-write/Multi-read?
shared


More information about the Digitalmars-d-learn mailing list