On Wed, 2005-04-27 at 10:05 +0200, Jonas Bonn wrote: > > There's a bug open about using g_atomic_* stuff for GObjects though: > > > > http://bugzilla.gnome.org/show_bug.cgi?id=166020 > > Thanks. That's what I was looking for. > Looking at the patches, though, I still end up scratching my head over one bit: > > if (g_atomic_int_get (&object->ref_count) == 1) > G_OBJECT_GET_CLASS (object)->dispose (object); > > Why run dispose with the reference count at 1? It seems to be that it > would make more sense to drop the reference count to 0 (atomically) > and then run dispose. That way you ensure that the object is not > picked up again half-way through the dispose method where it's not > necessarily getting a coherent instance anymore. 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. Regards, Owen
Attachment:
signature.asc
Description: This is a digitally signed message part