mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-05 18:40:58 +01:00
gobject: drop OPTIONAL_BIT_LOCK_NOTIFY lock
Now all accesses to quark_notify_queue are guarded by the GData lock. Several non-trivial operations are implemented via g_datalist_id_update_atomic(). The OPTIONAL_BIT_LOCK_NOTIFY lock is thus unnecessary and can be dropped. Note that with the move to g_datalist_id_update_atomic(), we now potentially do more work while holding the GData lock (e.g. some code paths allocation additional memory). But note that g_datalist_id_set_data() already has code paths where it must allocate memory to track the GDataElt. Also, most objects are not used in parallel, so holding the per-object (per-GData) lock longer does not affect them. Also, many operations also require a object_bit_lock(), so it's unlikely that you really could achieve higher parallelism by taking more locks (and minimizing the time to hold the GData lock).
This commit is contained in:
parent
2197d7eaa9
commit
434a7a5082
@ -125,9 +125,8 @@ enum {
|
||||
* integers to GObjectPrivate. But increasing memory usage for more parallelism
|
||||
* (per-object!) is not worth it. */
|
||||
#define OPTIONAL_BIT_LOCK_WEAK_REFS 1
|
||||
#define OPTIONAL_BIT_LOCK_NOTIFY 2
|
||||
#define OPTIONAL_BIT_LOCK_TOGGLE_REFS 3
|
||||
#define OPTIONAL_BIT_LOCK_CLOSURE_ARRAY 4
|
||||
#define OPTIONAL_BIT_LOCK_TOGGLE_REFS 2
|
||||
#define OPTIONAL_BIT_LOCK_CLOSURE_ARRAY 3
|
||||
|
||||
#if SIZEOF_INT == 4 && GLIB_SIZEOF_VOID_P >= 8
|
||||
#define HAVE_OPTIONAL_FLAGS_IN_GOBJECT 1
|
||||
@ -713,15 +712,10 @@ g_object_notify_queue_freeze_cb (gpointer *data,
|
||||
static GObjectNotifyQueue *
|
||||
g_object_notify_queue_freeze (GObject *object)
|
||||
{
|
||||
GObjectNotifyQueue *nqueue;
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
nqueue = _g_datalist_id_update_atomic (&object->qdata,
|
||||
return _g_datalist_id_update_atomic (&object->qdata,
|
||||
quark_notify_queue,
|
||||
g_object_notify_queue_freeze_cb,
|
||||
object);
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
return nqueue;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@ -765,15 +759,11 @@ g_object_notify_queue_thaw (GObject *object,
|
||||
guint n_pspecs;
|
||||
GSList *slist;
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
|
||||
nqueue = _g_datalist_id_update_atomic (&object->qdata,
|
||||
quark_notify_queue,
|
||||
g_object_notify_queue_thaw_cb,
|
||||
((gpointer[]){ object, nqueue }));
|
||||
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
|
||||
if (!nqueue)
|
||||
return;
|
||||
|
||||
@ -870,8 +860,6 @@ g_object_notify_queue_add (GObject *object,
|
||||
{
|
||||
gpointer result;
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
|
||||
result = _g_datalist_id_update_atomic (&object->qdata,
|
||||
quark_notify_queue,
|
||||
g_object_notify_queue_add_cb,
|
||||
@ -882,8 +870,6 @@ g_object_notify_queue_add (GObject *object,
|
||||
.in_init = in_init,
|
||||
}));
|
||||
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_NOTIFY);
|
||||
|
||||
return GPOINTER_TO_INT (result);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user