questions about g_object_unref.



Hi all, not sure if it is appropriate here, but I don't quite understand
the code in g_object_unref:

glib-2.16.1/gobject/gobject.c: line:1763
  /* here we want to atomically do: if (ref_count>1) { ref_count--;
return; } */
 retry_atomic_decrement1:
  old_ref = g_atomic_int_get (&object->ref_count);
  if (old_ref > 1)
    {
      if (!g_atomic_int_compare_and_exchange (&object->ref_count,
old_ref, old_ref - 1))
    goto retry_atomic_decrement1;


How does the code achieve the goal stated in the comments? It seems to
me that the code will loop at retry_atomic_decrement1 untill old_ref ==
1?


Yu





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