On Thu, 04 Nov 2010 16:22:27 -0400, Andrei Alexandrescu
<[email protected]> wrote:
On 11/4/10 3:09 PM, Steven Schveighoffer wrote:
On Thu, 04 Nov 2010 15:55:07 -0400, Andrei Alexandrescu
<[email protected]> wrote:
On 11/4/10 2:45 PM, Steven Schveighoffer wrote:
On Thu, 04 Nov 2010 14:38:59 -0400, Andrei Alexandrescu
<[email protected]> wrote:
I think this can be made to work and has good properties, although a
fair amount of details need to be figured out. Please share any
thoughts you may have.
What if a thread no longer exists? Would there be a way to mark such
dtors that need this feature?
Probably a thread that dies (by crashing) will never call its
destructors.
It is quite possible that a thread exits while there are active,
non-GC'd objects owned by it in the heap. There's no way to determine
this when the thread exits without running a GC collection, which is
unacceptable.
Oh, I see. Indeed, thread cleanup code should also go down the worklist
and call destructors. By definition, no unshared objects should be
visible by other threads.
Well, yes, but not exactly :) You see, an object could not have been
targeted for destruction by the GC until *after* the thread that allocated
it has exited. I suspect that the right answer here is for the GC to just
destroy it, but if it's not equipped to run those dtors, it might be a
sticky thing to implement.
So the object isn't in the worklist when the thread exits, and it doesn't
get marked for destruction until some other thread runs a GC cycle.
-Steve