digitalmars.D.learn - Deprecation: Read-modify-write operations are not allowed for shared
- Timothee Cour via Digitalmars-d-learn (7/7) Aug 12 2014 dmd 2.066(rc) generates warning: 'Deprecation: Read-modify-write operati...
- anonymous (8/17) Aug 12 2014 I think yes.
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?
Aug 12 2014
On Tuesday, 12 August 2014 at 10:01:46 UTC, Timothee Cour via Digitalmars-d-learn wrote: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?I think yes. Only this specific block is synchronized (only one thread can run it at a time). Other accesses of `a` elsewhere are not synchronized with this one. If you know that this `synchronized` block is enough to make it safe, you can cast shared away.
Aug 12 2014