Re: [gtk-list] Re: Proxy objects and circular garbage



Vollmer Marius <mvo@zagadka.ping.de> writes:

> A solution for Guile could be to only mark the SCM stuff that hangs
> off of a GtkObject while marking the object itself.
> 
> I'm coming back to you when I have made my mind up.

Right, I think I have something now.

I have implemented the following scheme in guile-gtk: Neither the
proxy->gtk link nor the gtk->proxy link is weak.  As long as one of
these objects is alive, the other is forced to be alive, too.  The
problems with cycles is prevented by incorporating the gtk objects
into the tracing mark/sweep GC of Guile.  Guile-gtk keeps a list of
all existing proxy objects.  These list is traversed during the mark
phase of the GC and all proxies that point to gtk objects with a
reference count > 1 are marked.  When a gtk object has a ref count > 1
it means tht someone else besides Scheme has a reference to it.

Marking a proxy involves marking all Scheme values that are
`protected' by the gtk object of the proxy.  These protected values
are all those Scheme values that are in use by the gtk object, such
assignal handlers.  Ideally, Gtk itself will perform the enumeration
of all used foreign values, but ti doesn't.  So I had to add
information to gtk.defs that says what function installs such values
into what objects.  gtk_signal_connect for example installs the
handler into the gtk object passed as the first parameter;
gtk_timeout_add has no such object and thus the callback is put onto a
gloabl list of protected values.

Ok, do you spot any problems with this?

I'll upload the new, improved guile-gtk in a couple of days I think.
There are some performance improvements in it and but the best thing
is probably that you can almost use it cleanly for wrapping third
party stuff, like the gnome libraries, or widgets distributed
independently from Gtk+.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]