GC Destruction Order

bitwise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 19 15:15:18 PDT 2015


On Tue, 19 May 2015 17:52:36 -0400, rsw0x <anonymous at anonymous.com> wrote:

> On Tuesday, 19 May 2015 at 21:07:52 UTC, bitwise wrote:
>> Any idea what the plans are?. Does RefCounted become thread safe?
>>
>> Correct me if I'm wrong though, but even if RefCounted itself was  
>> thread-safe, RefCounted objects could still be placed in classes, at  
>> which point you might as well use a GC'ed class instead, because you'd  
>> be back to square-one with your destructor racing around on some random  
>> thread.
>>
>
> I don't understand what you're asking here. If you hold a RefCounted  
> resource in a GC managed object, yes, it will be tied to the GC object's  
> lifetime.
>
> With your avoidance of the GC, I feel like you were lied to by a C++  
> programmer that reference counting is the way to do all memory  
> management, when in reality reference counting is dog slow and destroys  
> your cache locality(esp. without compiler support.) Reference counting  
> is meant to be used where you need absolute control over a resource's  
> lifetime(IMHO,) not as a general purpose memory management tool.

Thanks for confirming, but given your apparent tendency toward pinhole  
view points, it's unsurprising that you don't understand what I'm asking.

   Bit


More information about the Digitalmars-d-learn mailing list