Sharing in D

Sean Kelly sean at invisibleduck.org
Fri Aug 1 08:00:08 PDT 2008


== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> superdan wrote:
> > Walter Bright Wrote:
> >>> So "shared" will tell the compiler to automatically fence, etc?
> >> Yes.
> >
> > yech. so i write this:
> >
> > ++a; ++b; ++c;
> >
> > and very different code comes down the pike depending on a or b or c
> > being shared. not easy to clarify the code is correct. this ain't
> > cool.
> If conventional code were generated for i++, and i was accessed from
> multiple threads, the code is *broken*.

Not necessarily.  If i is a 32-bit number and only one thread is
doing the writing then the code could be perfectly safe.


Sean



More information about the Digitalmars-d mailing list