DIP 1024---Shared Atomics---Final Review

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 10 16:05:27 UTC 2019

On 12/10/19 10:13 AM, Simen Kjærås wrote:
> On Tuesday, 10 December 2019 at 12:18:39 UTC, RazvanN wrote:
>> On Sunday, 8 December 2019 at 16:25:21 UTC, Mike Parker wrote:
>> If you have a const shared variable, do you still need locks to read it?
> You'll need to cast away shared. You can of course do that without 
> locks, but you probably shouldn't.
> The reason is that, even though const ensures *you* cannot modify it, 
> others may, and you risk reading inconsistent data.

This only makes sense for const references. A const variable is const.

Like a const int. Nobody can modify it, because the storage class is 
const, it's impossible (without casting away const) to get a mutable 

So I think it's OK not to lock, but yes, you should have to cast away 


More information about the Digitalmars-d mailing list