shared - i need it to be useful

Timon Gehr timon.gehr at gmx.ch
Tue Oct 16 10:15:51 UTC 2018


On 15.10.2018 20:46, 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?
> 

Unshared becomes useless, and in turn, shared becomes useless. You can't 
have unshared/shared aliasing.

> All the risks that I think have been identified previously assume that
> you can arbitrarily modify the data. That's insanity... assume we fix
> that... I think the promotion actually becomes safe now...?

But useless, because there is no way to ensure thread safety of reads 
and writes if only one party to the shared state knows about the sharing.


More information about the Digitalmars-d mailing list