Deprecation: Read-modify-write operations are not allowed for shared variables

2014-08-12 Thread Timothee Cour via Digitalmars-d-learn
dmd 2.066(rc) generates warning: 'Deprecation: Read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!-=(a, 1) instead.' for following code: synchronized { ++a; } Is that correct given that it's inside synchronized?

Re: Deprecation: Read-modify-write operations are not allowed for shared variables

2014-08-12 Thread ketmar via Digitalmars-d-learn
On Tue, 12 Aug 2014 03:01:22 -0700 Timothee Cour via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is that correct given that it's inside synchronized? yes. synchronized doesn't lock *any* access to a (consider two different shared classes, for example), it just prevents

Re: Deprecation: Read-modify-write operations are not allowed for shared variables

2014-08-12 Thread Sean Kelly via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 15:06:38 UTC, ketmar via Digitalmars-d-learn wrote: besides, using atomic operations will allow you to drop synchronize altogether which makes your code slightly faster. ... and potentially quite broken. At the very least, if this value is ready anywhere

Re: Deprecation: Read-modify-write operations are not allowed for shared variables

2014-08-12 Thread ketmar via Digitalmars-d-learn
On Tue, 12 Aug 2014 16:02:01 + Sean Kelly via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ... and potentially quite broken. At the very least, if this value is ready anywhere you'll have to use an atomicLoad there in place of the synchronized block you would have used.