gst/gstminiobject.c: When replacing a miniobject, do a quick equality check first so that we can avoid a ref/unref pair.

Original commit message from CVS:
* gst/gstminiobject.c: (gst_mini_object_replace):
When replacing a miniobject, do a quick equality check first so that we
can avoid a ref/unref pair.
This commit is contained in:
Wim Taymans 2008-02-01 10:23:56 +00:00
parent 698ecfc5fd
commit 6f0a59aa13
2 changed files with 14 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2008-02-01 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/gstminiobject.c: (gst_mini_object_replace):
When replacing a miniobject, do a quick equality check first so that we
can avoid a ref/unref pair.
2008-02-01 Wim Taymans <wim.taymans@collabora.co.uk>
* docs/design/part-synchronisation.txt:

View file

@ -364,13 +364,18 @@ gst_mini_object_replace (GstMiniObject ** olddata, GstMiniObject * newdata)
newdata, newdata ? newdata->refcount : 0);
#endif
olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
if (olddata_val == newdata)
return;
if (newdata)
gst_mini_object_ref (newdata);
do {
while (!g_atomic_pointer_compare_and_exchange ((gpointer *) olddata,
olddata_val, newdata)) {
olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
} while (!g_atomic_pointer_compare_and_exchange ((gpointer *) olddata,
olddata_val, newdata));
}
if (olddata_val)
gst_mini_object_unref (olddata_val);