Prime sieve language race
ag0aep6g
anonymous at example.com
Thu Jul 15 15:13:44 UTC 2021
On Thursday, 15 July 2021 at 13:16:01 UTC, Sebastiaan Koppe wrote:
> Yes that is the sensible thing to do. But I am not sure that is
> the right thing. I am afraid that it will lead to the
> conclusion that everything needs to be shared, because who is
> going to stop someone from taking your struct/class/function,
> moving it over to another thread and then complain it corrupts
> memory while it was advertised as having a @safe interface?
If you share an object between threads, it must be typed as
`shared`. Then someone can only call those methods that are also
marked `shared`. Those methods are thread-safe. If someone casts
`shared` away, it's on them to ensure thread-safety.
More information about the Digitalmars-d
mailing list