This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Marking smobs for GC


Greg Harvey <Greg.Harvey@thezone.net> writes:

> Marius Vollmer <mvo@zagadka.ping.de> writes:
> 
> > Greg Harvey <Greg.Harvey@thezone.net> writes:
> > 
> > > Maybe this would be a bit easier with guardians?
> > 
> > You mean, I could just let the proxy/widget move into a guardian when
> > there are no references to it from Scheme and then, after the GC, do
> > the internal reference boogie to find out which of them are really
> > dead and resurrect the rest?  Yes, that could work.  It would be
> > basically the same as what I'm doing now, but probably more efficient.
> 
> Actually, you could just slap it into a guardian from the beginning,
> and look at the dead ones after collection. If they aren't really
> dead, put them back into the guardian.

That's what I thought too.  Should be safe as long as the garbage
collector is not timer-activated ;).

BTW, it would really be helpful to have a post-GC hook or somesuch
in Guile, so that people could attach things to it.

> Here's how I understand it: you have a widget foo, that you just
> created. On the gtk side of things, it keeps a reference count; on the
> scheme side of things, you put the scheme object of the widget into
> the widget guardian. You do a bunch of stuff, and then all references
> to foo's scheme object are dropped. On the next collection, foo
> becomes a zombie. After that, you look at the widget zombies. foo
> still has a gtk refcount greater than 1, so you put foo back into the
> guardian. I'm probably over-simplifying the widget relationships,
> though.
> 
> -- 
> Greg

m.