Variable modified by different threads.
Andy Valencia
dont at spam.me
Tue Dec 3 23:33:56 UTC 2024
On Tuesday, 3 December 2024 at 23:16:00 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> What owned by a thread means is that a pointer is guaranteed to
> only be accessible by that thread. I.e. the cpu will segfault
> if you try to access it from another thread.
My experience is that aside from thread-local module globals, all
other objects you create can be subsequently cast to shared and
then sent on to another thread. It can be accessed on the
receiving thread as such, or cast back to un-shared and used as
just another private data structure.
In fact, parts of Phobos will not work with objects having a
shared attribute. So you have to be careful about transferring
ownership for such data structures, and verifying your code path
guarantees exclusive access before casting it back to unshared.
Andy
More information about the Digitalmars-d-learn
mailing list