Synchronisation help

user1234 user1234 at 12.de
Tue Jan 2 19:52:49 UTC 2024


On Tuesday, 2 January 2024 at 11:39:12 UTC, Anonymouse wrote:
> On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote:
>> Do not use `shared` AA. Use `__gshared` + sync primitives. 
>> `shared` AA will lead to all sort of bugs:
>>
>> - https://issues.dlang.org/show_bug.cgi?id=20484#c1
>> - https://issues.dlang.org/show_bug.cgi?id=17088
>> - https://issues.dlang.org/show_bug.cgi?id=16597
>> - etc.
>
> Hmm, I see.
>
> Is `shared` safe to use with AAs *provided* I use sync 
> primitives, or should I favour `__gshared` over `shared`? I was 
> under the impression `__gshared` was only really meant for 
> interfacing with C.

The semantics of __gshared in this context is "no-TLS". You meant 
to access the AA in several threads right ? So you dont want each 
thread to have its own copy.


More information about the Digitalmars-d-learn mailing list