On Wednesday, 30 September 2020 at 20:13:47 UTC, IGotD- wrote:
This where the memory model of D starts to become confusing for me. By default memory allocations/deallocation are not allowed between threads, however setting the object to shared circumvents this. This seems to work as there is no more aborts from the D memory management. However, this has a weird side
I think declaring the container and item as `shared` is the D's encouraged way of sharing data among different threads.
effect. Now the compiler wants that all my integer member variables operates by using atomic primitives. I don't need this, I know that this object will be sequentially used.
then just cast the `shared` away: cast()data.
Is shared the wrong way to go here and is there another way to solve this?
I think using `shared` is the D's encouraged way. If there is a better way do this in D, I'd want to know it too.