shared - i need it to be useful

Erik van Velzen erik at evanv.nl
Thu Oct 18 19:04:58 UTC 2018


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.

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


You can still disagree on the merits, but so far it has been 
demonstrated as a sound idea.


More information about the Digitalmars-d mailing list