GC Destruction Order

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 21 05:33:38 PDT 2015


On 5/20/15 11:09 AM, Kagamin wrote:
> On Wednesday, 20 May 2015 at 13:54:29 UTC, bitwise wrote:
>> Yes, but D claims to support manual memory management. It seems to get
>> second class treatment though.
>
> It's WIP. There were thoughts to run finalizers on the thread where the
> object was allocated (I doubt it's a good idea, though).

It's essential for lockless thread-local programming.

At this moment, a thread-local-only heap pointer must deal with 
multi-threading issues simply because destructors can run on another 
thread, even though the reference is thread-local. The biggest example 
right now is reference-counted structures such as std.stdio.File.

The absolute best part about the shared qualifier is the lack of shared 
qualifier -- you can be certain something isn't shared if it doesn't 
have shared attached to it. Right now, even in that case, you still have 
to worry about RAII objects being destroyed in other threads. We 
shouldn't have to worry about that.

-Steve


More information about the Digitalmars-d-learn mailing list