On Monday, 1 January 2024 at 15:48:16 UTC, Anonymouse wrote:
I have a `shared string[int]` AA that I access from two
different threads. The function I spawn to start the second
thread takes the AA as an argument.
[...]
What is the common solution here? Do I add a module-level
`Object thing` and move everything accessing the AA into
`synchronized(.thing)` statements? Or maybe add a `shared
static` something to `Foo` and synchronise with
`synchronize(Foo.thing)`?
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.