...We've got ordered destruction on the big list 'o things to do, and it looks like we need to get that done sooner rather than later.
Not a huge task, we just need to order PMCs before destroying them, to
make sure we don't call the destructor for a PMC before we destroy the
things that depend on it. A quick run through the PMC pools to build up a
dependency chain if there's more than one PMC that needs destruction
should do it.
I have a partial implementation of this now. (Need to clean it up before submitting it.) There are a couple of thorny points that may need some discussion, but I'll start with the sharpest thorn: For PMCs with a custom mark method, the idea is that it's opaque exactly what other object they have references to, right? (That is, the PMC knows how to mark them alive, but doesn't reveal what they are, right?)
I'm asking because my approach is to collect the list of PMCs which need their destroys called, and trace through this set (like a DOD run) to see which ones are referred to by others on the list (and more importantly, which ones are not), destroy() those that are unreferenced and take them off the list (or do this to an arbitrary one if none are unreferenced), and repeat until done. This works out fine, but I don't think I can use the PObj_live_FLAG for this marking or it will mess up the subsequent work in free_unused_pobjects(), but there isn't a way to ask a mark() method to set another flag. This leaves me stuck with regard to PMCs with custom mark methods (but it's working for the other PMC flavors of referring).
So, I wanted to see if I'm missing something obvious, or if we need for mark() to take a parameter to indicate the flag to set.
(For a second I was about to decide that I could re-use PObj_live_FLAG, since by definition it will be unset for objects we are going to destroy(), thinking that I just need to be sure to clear the flag again before getting to the rest of free_unused_pobjects(), but since there's no unmark() method I'm again stuck, since my tracing could inadvertently appear to bring things back to life. Though I suppose a subsequent DOD run would get them....)
Thoughts?
JEff