Re: Atomic Reference Counts in GObject
- From: Jonas Bonn <jonas bonn gmail com>
- To: Owen Taylor <otaylor redhat com>, gtk-devel-list gnome org
- Cc:
- Subject: Re: Atomic Reference Counts in GObject
- Date: Wed, 27 Apr 2005 17:16:53 +0200
> Dispose methods are allowed to resurrect objects. One g_object_unref()
> has been called on an object with a refcount of 1, there are no
> *external* references to the object by definition ... no other
> thread can hold a reference to the object, or the refcount would be 2.
Unless there are weak references to the object... while the dispose
method is running, I can still grab a reference to the object in
another thread through the weak references I have. If the dispose
method is meanwhile busy dismantling the object, I will get an object
that's no longer coherent... I'd have to add checks everywhere to make
sure that all the references held by the (possibly half-disposed)
object are still valid before I use them.
Drop the reference count to 0 and calling g_object_ref on the weak
reference will fail... obviously, I know the weak reference is no
longer valid and that the notifier will be called shortly.
Or call the weak notifiers before disposing the object so that I know
to remove the weak reference from my list and to not even bother to
try to reference it.
Hope this makes sense...
Jonas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]