[dmd-concurrency] shared arrays, real, shared classes, synchronized classes

Andrei Alexandrescu andrei at erdani.com
Fri Jan 29 18:00:50 PST 2010


Brad Roberts wrote:
> On Fri, 29 Jan 2010, Andrei Alexandrescu wrote:
> 
>> Rationale: it is tenuous to offer mixed modes in the same class.
>>
>> 4. The "synchronized" attribute is hoisted at class level:
>>
>> synchronized class A { ... }
>>
>> That means each and every method of that class is synchronized.
>>
>> 5. The "shared" attribute is hoisted at class or struct level:
>>
>> shared class A { ... }
>> shared struct B { ... }
>>
>> That means the implementation is lock-free and uses its own synchronization
>> mechanisms.
>>
>> 6. When defining an object of a synchronized of shared type, you still need to
>> qualify it with "shared" in order to make it so. For example:
>>
>> synchronized class A { ... }
>> shared A a; // fine
>> A b;        // error
>>
>> (I'm not 100% sure about this.)
> 
> What are the rules for these two attributes (add 'scope' to the list too) 
> behave in terms of class hierarchies?

Good question! I am not sure.

The simplest mechanism is to impose preservation of threading style. 
Other ideas?


Andrei



More information about the dmd-concurrency mailing list