Something needs to happen with shared, and soon.

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Nov 14 06:10:45 PST 2012


On 11/13/12 11:37 PM, Jacob Carlborg wrote:
> On 2012-11-13 23:22, Walter Bright wrote:
>
>> But I do see enormous value in shared in that it logically (and rather
>> forcefully) separates thread-local code from multi-thread code. For
>> example, see the post here about adding a destructor to a shared struct,
>> and having it fail to compile. The complaint was along the lines of
>> shared being broken, whereas I viewed it along the lines of shared
>> pointing out a logic problem in the code - what does destroying a struct
>> accessible from multiple threads mean? I think it must be clear that
>> destroying an object can only happen in one thread, i.e. the object must
>> become thread local in order to be destroyed.
>
> If the compiler should/does not add memory barriers, then is there a
> reason for having it built into the language? Can a library solution be
> enough?

The compiler must be in this so as to not do certain reorderings.

Andrei



More information about the Digitalmars-d mailing list