March 05, 2021
On 3/5/21 8:29 PM, Jack wrote:

> Now about the behavior of a static destructor, like static ~this() { }
> is this guaranteed to be run?

I don't know any way of creating a module on the GC heap so their destruction should not be related to GC collection. I would expect all 'static ~this()' blocks to be executed upon thread termination.

'shared static ~this()' blocks are said to be executed after main() exits in the following page but that description is not precise enough because 'shared static ~this()' blocks of a dynamic library would be executed when the library is unloaded.

  https://dlang.org/spec/class.html#SharedStaticConstructor

Ali

March 07, 2021
On Friday, 5 March 2021 at 20:28:58 UTC, Ali Çehreli wrote:
> To my surprise, even though 'c' is not null below, the destructor is not executed multiple times.
>

Hence why https://p0nce.github.io/d-idioms/#GC-proof-resource-class works as a detector of undeterminism.


1 2 3
Next ›   Last »