Non-atomic ops allowed on shared variables?
Jonathan M Davis
jmdavisProg at gmx.com
Sat Dec 3 11:37:18 PST 2011
On Saturday, December 03, 2011 20:22:40 David Nadlinger wrote:
> On 12/3/11 8:19 PM, Jonathan M Davis wrote:
> > Sure, if you use anything other
> > than an atomic operation on a shared object and don't use a synchronized
> > block or a mutex or the like, you risk race conditions, but if every
> > operation on a shared object had to actually be atomic, you couldn't do
> > much of anything to them.
> Isn't that exactly the point? What are the guarantees of shared
> otherwise? I agree that the current behavior is counter-intuitive and
I believe that it disallows the compiler from reordering operations on some
level, and the big thing of course is that it means that the object isn't
thread-local and _can_ be read by multiple threads. I haven't read TDPL's
section on shared in a while though, and I almost never use it, so there could
be something that I'm missing.
- Jonathan M Davis
More information about the Digitalmars-d-learn