Re: Atomic Reference Counts in GObject



> 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.

Jonas



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