Thread overview
Re: Deprecation: Read-modify-write operations are not allowed for shared variables
Aug 12, 2014
ketmar
Aug 12, 2014
Sean Kelly
Aug 12, 2014
ketmar
August 12, 2014
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 simultaneous access in this given part of code. so to be on the safe side, use atomic operations.

besides, using atomic operations will allow you to drop synchronize altogether which makes your code slightly faster.


August 12, 2014
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 you'll have to use an atomicLoad there in place of the synchronized block you would have used.
August 12, 2014
On Tue, 12 Aug 2014 16:02:01 +0000
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.
sure, *any* access to shared variables should be done with atomic ops. i thought that this is obvious. ;-)