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 wrapper
around an AA of the type I need, overload the required
operators, and then just drop-in replace the current AA? All
array operations would then transparently be between lock and
unlock statements.
[...]
I guess this can break synchronisation between the two if I
replace the `Mutex` in either thread. Are there any other
obvious caveats?
It might be, that this locking scheme is too narrow. E.g. you
might want to have an "atomic" testAndSet on the AA e.g. check if
an element is in and iff its not in put it there.
Kind regards,
Christian