On 2012-11-14 08:56, Jonathan M Davis wrote:

Being able to have double-checked locking work would be valuable, and having
memory barriers would reduce race condition weirdness when locks aren't used
properly, so I think that it would be desirable to have memory barriers. If
there's a major performance penalty though, that might be a reason not to do
it. Certainly, I don't think that there's any question that adding memory
barriers won't make it so that you don't need mutexes or synchronized blocks
or whatnot. shared's primary benefit is in logically separating normal code
from code that must shared data across threads and making it possible for the
compiler to optimize based on the fact that it knows that a variable is
thread-local.

If there is a problem with efficiency in some cases then the developer can use __gshared and manually handling things. But of course, we don't want the developer to have to do this in most cases.

--
/Jacob Carlborg

Reply via email to