[dmd-concurrency] is shared going to be a type modifier?
Andrei Alexandrescu
andrei at erdani.com
Thu Jan 7 12:18:17 PST 2010
Steve Schveighoffer wrote:
> ----- Original Message ----
>
>> From: Andrei Alexandrescu <andrei at erdani.com> Yes, shared is a type
>> qualifier. For the most part it behaves like immutable. Note that
>> you can define an immutable member of an otherwise mutable type.
>>
>
> Right, but this to me makes sense -- I want to define something that
> is always immutable. A piece of data becomes immutable the second
> you declare it is.
>
> But when I mark a class member shared, it does not truly become
> shared by declaring it that way -- allocating an instance of such a
> class does not make its shared members available to other threads.
> Compare that to a global, which is immediately shared. I think this
> is going to have to be really explained well. As a member storage
> class, shared really should be called "shareable".
>
> Despite that, I think I get it. The address to a shared member could
> be passed to other threads, even though the full object is not, is
> that correct?
Of course, plus the more frequent case is:
class SList { ... }
struct A { int x; shared SList lst; }
Andrei
More information about the dmd-concurrency
mailing list