synchronized class bugs?

Steven Schveighoffer schveiguy at gmail.com
Wed Apr 8 23:16:00 UTC 2020


On 4/8/20 6:50 PM, Gregor Mückl wrote:
> On Wednesday, 8 April 2020 at 13:43:08 UTC, Steven Schveighoffer wrote:
>> This is why we are moving to REQUIRING casting away shared to 
>> read/write data -- you have to do it anyway.
>>
> 
> OK, I understand the rationale, even though I don't like the solution 
> very much. You shouldn't really use atomic ops when locks on the 
> affected variables are held. That's bad practice.

No, you misunderstand. The correct path is to cast away shared for those 
variables that you manually ensure cannot be touched outside your class, 
not to use atomic ops.

But the compiler has no way to prove you did it right, which is why the 
casting is required.

The expectation is that frameworks that use this requirement will emerge 
that make this much more convenient.

> 
> The the full program code is below the line. You can run it on 
> run.dlang.org to reproduce the problem.

OK, will look to see what I can find.

-Steve


More information about the Digitalmars-d mailing list