mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
gobject: drop OPTIONAL_BIT_LOCK_TOGGLE_REFS lock
It was replaced by the GData lock and g_datalist_id_update_atomic(). Note that we introduced object_bit_lock() to replace global mutexes. Now, object_bit_lock() is also replaced, by using the GData lock via g_datalist_id_update_atomic(). This means, all mutex-like locks on the GObject now go through the GData lock on the GObject's qdata. For the moment, the object_bit_lock() API is still here and unused. It will be dropped in a separate commit.
This commit is contained in:
@@ -124,7 +124,7 @@ enum {
|
||||
* parallel as possible. The alternative would be to add individual locking
|
||||
* integers to GObjectPrivate. But increasing memory usage for more parallelism
|
||||
* (per-object!) is not worth it. */
|
||||
#define OPTIONAL_BIT_LOCK_TOGGLE_REFS 1
|
||||
#define OPTIONAL_BIT_LOCK_UNUSED 1
|
||||
|
||||
#if SIZEOF_INT == 4 && GLIB_SIZEOF_VOID_P >= 8
|
||||
#define HAVE_OPTIONAL_FLAGS_IN_GOBJECT 1
|
||||
@@ -624,7 +624,7 @@ weak_ref_data_has (GObject *object, WeakRefData *wrdata, WeakRefData **out_new_w
|
||||
static G_THREAD_LOCAL guint _object_bit_is_locked;
|
||||
#endif
|
||||
|
||||
static void
|
||||
G_GNUC_UNUSED static void
|
||||
object_bit_lock (GObject *object, guint lock_bit)
|
||||
{
|
||||
#if defined(G_ENABLE_DEBUG) && defined(G_THREAD_LOCAL)
|
||||
@@ -639,7 +639,7 @@ object_bit_lock (GObject *object, guint lock_bit)
|
||||
g_bit_lock ((gint *) object_get_optional_flags_p (object), _OPTIONAL_BIT_LOCK);
|
||||
}
|
||||
|
||||
static void
|
||||
G_GNUC_UNUSED static void
|
||||
object_bit_unlock (GObject *object, guint lock_bit)
|
||||
{
|
||||
#if defined(G_ENABLE_DEBUG) && defined(G_THREAD_LOCAL)
|
||||
@@ -4351,8 +4351,6 @@ toggle_refs_check_and_ref_or_deref (GObject *object,
|
||||
*toggle_notify = NULL;
|
||||
*toggle_data = NULL;
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
|
||||
/* This is called from g_object_ref()/g_object_unref() and a hot path.
|
||||
*
|
||||
* We hack the GData open and take the g_datalist_lock() outside. Then we
|
||||
@@ -4386,14 +4384,12 @@ toggle_refs_check_and_ref_or_deref (GObject *object,
|
||||
if (G_UNLIKELY (!success))
|
||||
{
|
||||
g_datalist_unlock (&object->qdata);
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (G_LIKELY (!OBJECT_HAS_TOGGLE_REF (object)))
|
||||
{
|
||||
g_datalist_unlock (&object->qdata);
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -4406,7 +4402,6 @@ toggle_refs_check_and_ref_or_deref (GObject *object,
|
||||
toggle_refs_check_and_ref_cb,
|
||||
(gpointer[2]){ toggle_notify, toggle_data });
|
||||
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -4499,8 +4494,6 @@ g_object_add_toggle_ref (GObject *object,
|
||||
|
||||
g_object_ref (object);
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
|
||||
_g_datalist_id_update_atomic (&object->qdata,
|
||||
quark_toggle_refs,
|
||||
toggle_refs_ref_cb,
|
||||
@@ -4511,8 +4504,6 @@ g_object_add_toggle_ref (GObject *object,
|
||||
.data = data,
|
||||
},
|
||||
}));
|
||||
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@@ -4585,8 +4576,6 @@ g_object_remove_toggle_ref (GObject *object,
|
||||
g_return_if_fail (G_IS_OBJECT (object));
|
||||
g_return_if_fail (notify != NULL);
|
||||
|
||||
object_bit_lock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
|
||||
result = _g_datalist_id_update_atomic (&object->qdata,
|
||||
quark_toggle_refs,
|
||||
toggle_refs_unref_cb,
|
||||
@@ -4598,8 +4587,6 @@ g_object_remove_toggle_ref (GObject *object,
|
||||
},
|
||||
}));
|
||||
|
||||
object_bit_unlock (object, OPTIONAL_BIT_LOCK_TOGGLE_REFS);
|
||||
|
||||
found_one = GPOINTER_TO_INT (result);
|
||||
|
||||
if (!found_one)
|
||||
|
Reference in New Issue
Block a user