shared vs __gshared

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 10 12:46:27 PDT 2013


On Monday, June 10, 2013 13:23:26 Steven Schveighoffer wrote:
> shared was supposed to infer memory barriers, but AFAIK, it doesn't do
> that. Not sure it ever will.

I believe that things are definitely leaning towards shared not adding memory 
barriers. There _might_ be something that happens with shared that relates to 
the GC in order to be able to facilitate per-thread collection, but at this 
point, I think that it's looking like shared will be almost like const in that 
it's a compile-time only thing enforced by the type system but has no effect at 
runtime (the main difference being that objects created as shared will be in 
shared memory rather than being thread-local - which _would_ be a difference at 
runtime - but aside from that, there may be no difference between shared and 
non-shared at runtime).

But I believe that ironing out shared is one of the things that Andrei wants 
to discuss and sort out soon based on his comments in recent discussions on 
whether we're going to make member functions non-virtual by default.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list