Re: weakref semantics
- From: jcupitt gmail com
- Cc: "Gtk+ Developers" <gtk-devel-list gnome org>
- Subject: Re: weakref semantics
- Date: Thu, 17 Jan 2008 14:32:12 +0000
On Jan 17, 2008 12:34 PM, Tim Janik <timj imendio com> wrote:
> On Thu, 17 Jan 2008, Alexander Larsson wrote:
> > On Wed, 2008-01-16 at 15:03 +0000, jcupitt gmail com wrote:
> >> I noticed the weakref introduction says that notifies can be called many times:
> >>
> >> http://library.gnome.org/devel/gobject/unstable/gobject-memory.html#gobject-memory-weakref
> >>
> >> ... which is invoked when the object runs its dispose method. As such,
> >> each weak ref can be invoked more than once upon object finalization
> >> (since dispose can run more than once during object finalization).
> >>
> >> I'm not sure this is right: looking at the source for gobject it seems
> >> that the notifies are a fire-once thing, and are removed upon firing.
> >>
> >> Should I open a docs bug on this? (or am I confused?)
>
> you mis the facts that new weak refs can be added at any point in time,
> such as after dispose, in finalize or even during weakref notifies.
> (that's actually the semantics of GObject's GData mechanism which
> is used to implement weakrefs)
Sorry Tim, I'm still confused.
I understand that weakrefs can be added at any time (and may therefore
be called after dispose has finished), but I don't think a single
weak_ref() can ever fire more than once. In other words, if I call:
g_object_weak_ref( obj, myfunction, somedata );
then
myfunction(somedata, obj)
is guaranteed to be called exactly once. Is that right? It seems to
contradict the docs I quoted above.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]