Shared

Dominikus Dittes Scherkl dominikus at scherkl.de
Sat May 11 09:51:41 UTC 2019


I've followed the AGM a little and think, why not go with the 
"disable access to shared" approach, but instead of allowing it 
to be casted away, introduce a "locked scope" lock { } which need 
to be within a function and allow access to shared variables only 
within such blocks?
It's still up to the user to ensure that such locked blocks 
encapsulate the semantic blocks which need to be kept together to 
safely modify shared variables, but at least the compiler can 
make sure they are not modified outside locked blocks and that at 
any time only one such block is executed on any thread. And such 
blocks should be scarce so they can be examined carefully like 
trusted and everything build upon is verifiable safe.


More information about the Digitalmars-d mailing list