Shared Hell

Walter Bright newshound1 at digitalmars.com
Thu Oct 29 11:34:55 PDT 2009


Kagamin wrote:
> Walter Bright Wrote:
>> A function that accesses shared data has to put in fences. There's
>> no way to have the same code deal with shared and unshared code.
> 
> Shared code perfectly deals with unshared data (it's not guaranteed
> that shared data is accessed by more than one thread). In other words
> unshared data is implicitly castable to shared.

Unfortunately, there is a subtle problem with that that makes such 
implicit casts unsafe. Shared data can be handed off to other threads. 
So if thread local data is implicitly cast to shared, then it can be 
handed off to other threads. Meaning it is no longer guaranteed to be 
thread local.



More information about the Digitalmars-d mailing list