Problem with clear on shared associative array?

Andy Valencia dont at spam.me
Sun May 26 20:15:54 UTC 2024


On Sunday, 26 May 2024 at 20:00:50 UTC, Jonathan M Davis wrote:
> No operation on an associative array is thread-safe. As such, 
> you should not be doing _any_ operation on a shared AA without 
> first locking a mutex to protect it. Then you need to cast away 
> shared to access or mutate it or do whatever it is you want to 
> do with it other than pass it around. And then when you're 
> done, you make sure that no thread-local references to the AA 
> exist, and you release the mutex.
> ...

Thank you, that's exactly the big picture explanation I was 
hoping for.

For others wrestling with this issue, I found out how to cast to 
unshared at this article:

https://forum.dlang.org/thread/jwasqvrvkpqzimlutgrm@forum.dlang.org

Andy



More information about the Digitalmars-d-learn mailing list