What exactly shared means?

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 2 14:10:34 PST 2015


On Friday, 2 January 2015 at 21:06:03 UTC, John Colvin wrote:
> Hmm. I went in to writing that thinking "shared isn't so bad". 
> Now I've thought about it, it is pretty damn useless. What's 
> the point of knowing that data is shared without knowing how to 
> safely use it? I guess it protects against completely naive 
> usage.

The real issue with "shared" is that objects may change status 
during runtime based on the state of the program.

What you really want to know is when a parameter is "local", that 
is, guaranteed to not be accessed by another thread during the 
execution of the function. If so you open up for optimizations.


More information about the Digitalmars-d-learn mailing list