mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-25 03:17:52 +02:00
Merge branch 'more-atomic-ops' into 'main'
Use atomic exchange operations more See merge request GNOME/glib!2759
This commit is contained in:
@@ -163,11 +163,18 @@ _g_atomic_array_update (GAtomicArray *array,
|
||||
guint8 *old;
|
||||
|
||||
G_LOCK (array);
|
||||
old = g_atomic_pointer_get (&array->data);
|
||||
old = g_atomic_pointer_exchange (&array->data, new_data);
|
||||
|
||||
#ifdef G_DISABLE_ASSERT
|
||||
if (old && G_ATOMIC_ARRAY_DATA_SIZE (new_data) < G_ATOMIC_ARRAY_DATA_SIZE (old))
|
||||
{
|
||||
g_atomic_pointer_set (&array->data, old);
|
||||
g_return_if_reached ();
|
||||
}
|
||||
#else
|
||||
g_assert (old == NULL || G_ATOMIC_ARRAY_DATA_SIZE (old) <= G_ATOMIC_ARRAY_DATA_SIZE (new_data));
|
||||
#endif
|
||||
|
||||
g_atomic_pointer_set (&array->data, new_data);
|
||||
if (old)
|
||||
freelist_free (old);
|
||||
G_UNLOCK (array);
|
||||
|
Reference in New Issue
Block a user