Re: Synchronisation help

2024-01-03 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 18:01:55 UTC, Jonathan M Davis wrote: [...] That clarifies a lot. If nothing else, I realise now I can't have `opBinaryRight(string op : "in")` the way I had hoped. What I have now probably doesn't cover 100% of every use-case, but it should do for my scope.

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
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 -

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 2, 2024 3:41:55 AM MST Anonymouse via Digitalmars-d-learn wrote: > On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: > > [...] > > Thank you. Yes, `Foo` is a class for the purposes of inheritance > -- I left that out of the example. > > So a completely valid

Re: Synchronisation help

2024-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 2, 2024 4:39:12 AM MST Anonymouse via Digitalmars-d-learn 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: > > > > -

Re: Synchronisation help

2024-01-02 Thread Christian Köstlin via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 10:41:55 UTC, Anonymouse wrote: On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
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 -

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
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`

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct wrapper around an AA of the type I need, overload the required

Re: Synchronisation help

2024-01-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 1 January 2024 at 15:48:16 UTC, Anonymouse wrote: 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

Re: Synchronisation help

2024-01-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 1, 2024 8:48:16 AM MST Anonymouse via Digitalmars-d-learn 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. > > ```d > class Foo > { > shared string[int]