On Thursday, 18 October 2018 at 19:04:58 UTC, Erik van Velzen wrote:
On Thursday, 18 October 2018 at 17:47:29 UTC, Stanislav Blinov wrote:
On Thursday, 18 October 2018 at 17:17:37 UTC, Atila Neves wrote:
On Monday, 15 October 2018 at 18:46:45 UTC, Manu wrote:
Assuming the rules above: "can't read or write to members", and the understanding that `shared` methods are expected to have threadsafe implementations (because that's the whole point), what are the risks from allowing T* -> shared(T)* conversion?

int i;
tid.send(&i);
++i;  // oops, data race

Doesn't work. No matter what you show Manu or Simen here they think it's just a bad contrived example. You can't sway them by the fact that the compiler currently *prevents* this from happening.

Manu said clearly that the receiving thread won't be able to read or write the pointer.

Not directly - but obviously there must be *some* way to using it, in this case since it's an int with one of the core.atomic functions. At that point the spawned thread will be accessing it correctly, but the parent thread can modify the int in a non-atomic fashion.

Because int or int* does not have threadsafe member functions.

https://dlang.org/phobos/core_atomic.html



Reply via email to