Destruction in D

weaselcat via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 30 13:13:19 PDT 2015


On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote:
> After reading GC page in the reference, it seems that class 
> destructors are called on a separate thread, in parallel to the 
> main thread. Is this correct?

There's no guarantee what thread will be used in the standard GC 
implementation AFAIK.

>
> What about structs? Are the destructors called when they go out 
> of scope in a C++ RAII fashion, or do they happen on a separate 
> thread too?

If they're on the stack(not allocated with `new`), then they have 
their destructor called upon leaving scope ala C++ RAII, 
otherwise see above.


More information about the Digitalmars-d-learn mailing list