On Tuesday, 12 May 2015 at 12:31:35 UTC, Adam D. Ruppe wrote:
Let me suggest a completely different option: make a destructor
that works while the GC is running by managing the resources
manually in both construction and destruction.
I see, but not all ressources can be disposed by any thread. I'd
prefer to make it an error. Also, relying on GC destructors can
make a program work by mistake.
isn't *all* reference types that are problematic to access, it
is just GC managed references. So anything from a C function is
cool.
Otherwise, accessing the runtime variable seems ok to me like
the link said, hacky sure, but it'd work.... nothing else comes
to mind, other than using a separate dispose() method when you
delete it manually and leave the dtor for only the GC.
I already have such a dispose() function.
The problem is that to support Unique! and scoped! and friends,
the destructor must call dispose(). Thus my need for a way to
separate the GC-induced destructors within dispose() or ~this
(same problem).