mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gdataset: Use atomic compare and exchange full to set pointers
In case first exchange failed we can avoid repeating the pointer get operation given that exchange full can provide us the old value.
This commit is contained in:
parent
08aee6b5f4
commit
e54f27322d
@ -145,11 +145,12 @@
|
||||
((GData*) ((gsize) g_atomic_pointer_get (datalist) & ~(gsize) G_DATALIST_FLAGS_MASK_INTERNAL))
|
||||
|
||||
#define G_DATALIST_SET_POINTER(datalist, pointer) G_STMT_START { \
|
||||
gpointer _oldv, _newv; \
|
||||
gpointer _oldv = g_atomic_pointer_get (datalist); \
|
||||
gpointer _newv; \
|
||||
do { \
|
||||
_oldv = g_atomic_pointer_get (datalist); \
|
||||
_newv = (gpointer) (((gsize) _oldv & G_DATALIST_FLAGS_MASK_INTERNAL) | (gsize) pointer); \
|
||||
} while (!g_atomic_pointer_compare_and_exchange ((void**) datalist, _oldv, _newv)); \
|
||||
} while (!g_atomic_pointer_compare_and_exchange_full ((void**) datalist, _oldv, \
|
||||
_newv, &_oldv)); \
|
||||
} G_STMT_END
|
||||
|
||||
/* --- structures --- */
|
||||
|
Loading…
Reference in New Issue
Block a user