Acess variable that was set by thread
anonymous at example.com
Mon Aug 8 14:12:08 UTC 2022
On Monday, 8 August 2022 at 13:31:04 UTC, Steven Schveighoffer
> On 8/8/22 6:17 AM, ag0aep6g wrote:
>> Never ever use `__gshared` ever. It's a glaring safety hole.
>> Use `shared` instead.
> If you are interfacing with C, you need __gshared. But yeah,
> you should use shared in this case.
A quick test suggests that `extern(C) extern shared` works fine.
As far as I can tell, `__gshared` is only ever ok-ish when you
want to access a shared C variable in a single-threaded program.
And then you're still setting yourself up for failure if you
later add more threads.
So, never ever use `__gshared` (in multi-threaded code) ever.
More information about the Digitalmars-d-learn