Thomas Fjellstrom writes:
> On October 9, 2003 09:57 am, Dan Sugalski wrote:
> > On Thu, 9 Oct 2003, Dave Mitchell wrote:
> > > On Thu, Oct 09, 2003 at 11:43:41AM -0400, Dan Sugalski wrote:
> > > > 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. So, this
> > > > is a good chance for someone to burn those surplus SAN points and
> > > > become one with the great gibbering chaos at the center of the universe
> > > > (no, wait, that's not it) by digging into the DOD system.
> > > >
> > > > 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 always thought that was a rather hard issue, due to circular
> > > dependencies. It's certainly the case that Perl5 is very poor at global
> > > destruction of objects.
> >
> > In the circular case you just pick a place and go from there -- there's no
> > good way to handle those. There are a lot of cases where there are
> > non-circular dependencies, though, so it seems worthwhile to take those in
> > order. Probably ought to be optional for all the sweeps except, perhaps,
> > the final one, though I expect perl, python, and ruby code will all enable
> > ordered destruction.
> 
> I've been interested in how to clean up circular dependencies... Just how easy 
> is it to find all cases? Is it possible? Like say a really really deep 
> case... Should you just not care at that point, and say the programmer 
> deserves what [s]he gets?

Well, you don't really need to *find* the circular dependencies,
considering you can't really do anything with them once you do.

To destroy in a good order, you just have to topologically sort the
dependency graph, which isn't terribly hard.  The way circular
dependencies are destroyed depends on the edge cases of the topological
sort algorithm you use.  It would probably be best to 'prefer' objects
with explicit destructors, such that they appear earlier in the sort.

Luke

> >                                     Dan
> 
> -- 
> Thomas Fjellstrom
> [EMAIL PROTECTED]
> http://strangesoft.net
> 

Reply via email to