On Sat, 2009-01-10 at 13:07 -0500, Yu Feng wrote:
> On Sat, 2009-01-10 at 18:35 +0100, Jürg Billeter wrote:
> > Right, but I'm not sure that you need to change anything in the unref
> > function to get dispose functionality working. Can you explain more
> > specifically what you can't get working with the current possibilities?
> > 
> 
> Yes I can do this:
> 
> class Object {
>    Object ref_to_there;
>    Object ref_to_here;
>    private disposed = false;
>    public virtual void dispose() {
>          /*release references here*/
>       ref_to_there = null;
>       ref_to_here = null;
>    }
>    private void run_dispose() {
>       if(disposed) return;
>       disposed = true;
>       dispose();
>    }
>    public void destroy() {
>       Object holder = this; 
>       /*needed if invoked from a weak reference of this*/
>       run_dispose();
>       holder = null;
>    }
> }
> 
> Then Object.destroy can be used to manifestly break any cycle
> references.
> 
> I was thinking about auto-cycle-breaking but it is unfortunately beyond
> my knowledge.

Unfortunately, there is no magic trick to break reference cycles
automatically in a simple way. In general, this requires an additional
garbage or cycle collector which scans stack and heap.

Jürg

_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to