[dmd-concurrency] What is shared?

Andrei Alexandrescu andrei at erdani.com
Sun Jan 3 16:34:07 PST 2010


This is a great discussion opener. I'll continue with a related question 
later. For now, the short answer is: "shared" is used to mark objects 
that may be shared across threads. Conversely, an object _not_ marked as 
"shared" is definitely visible only within one thread. This is 
information known statically.

The bugs you mention are serious. Walter, could you please give them 
priority? Thanks.


Andrei

Jason House wrote:
> On digitalmars.D, I've seen a lot of confusion about how shared 
> should/does work. I don't know of any formal documentation on this. 
> Maybe that'd be a side goal for this list?
> 
> Certainly, shared is transitive just like const or immutable. Non-shared 
> instances can't call shared functions and shared instances can only call 
> shared functions.
> 
> I know of at least one exception to that: auto x = new shared(T)(); will 
> call T's this() which is can not be marked as shared (bugzilla 3640). 
> I'm not sure about other special functions. It also isn't possible to 
> have both a shared and a non-shared version of template functions 
> (bugzilla 3660). 3660 has stopped my use of shared dead in its tracks.
> 
> While I'm listing bugzilla stuff, 3642's awful error message seems 
> relevent. When that message shows up more meaningful scenarios there are 
> other more helpful error messages that are also printed.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency


More information about the dmd-concurrency mailing list