Am 13.11.2012 23:22, schrieb Walter Bright:

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.


I still don't agree with you there. The struct would have clearly outlived any thread (as it was in the global scope) so at the point where it is destroyed there should be really only one thread left. So it IS destroyed in a single threaded context. The same is done for classes by the GC just that the GC ignores shared altogether.

Kind Regards
Benjamin Thaut


Reply via email to