shared - no read/write access

Stefan Koch uplink.coder at googlemail.com
Wed Mar 20 13:25:01 UTC 2019


On Tuesday, 19 March 2019 at 21:20:58 UTC, Kagamin wrote:
> On Tuesday, 19 March 2019 at 20:08:37 UTC, Manu wrote:
>> Last time we talked about shared, I think we all agreed on one 
>> thing; shared should hot have read/write access to data 
>> members.
>>
>> Does anyone know how to implement this? I would really like to 
>> try some important experiments with shared if it worked.
>
> shared qualifier provides a guarantee that thread local data is 
> thread local, it doesn't provide safety for concurrency, not 
> supposed to, because it's not realistically feasible at such 
> low level, and attempts to do it like yours only add noise, 
> complicate reasoning and make errors only more likely. Normally 
> it's unshared data that should have a qualifier, because that's 
> actually a feature being provided, but because it would be a 
> nuisance, the opposite was done.

In it's current form the `shared` qualifier is not improving the 
thread-safety
of D code. Manus proposal does improve thread-safety.
I am strongly in favor for considering it seriously.

Being conservative and disallowing all access is by far the most 
sensible handling
if safety is a concern.


More information about the Digitalmars-d mailing list