[glib/wip/gproperty-2: 17/19] gobject: Add quark-based locking
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gproperty-2: 17/19] gobject: Add quark-based locking
- Date: Tue, 11 Jun 2013 13:33:55 +0000 (UTC)
commit 7edd17290f3158f8ff2d5f1cafa13030e8770f85
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri May 3 17:16:33 2013 -0700
gobject: Add quark-based locking
https://bugzilla.gnome.org/show_bug.cgi?id=648526
gobject/gobject.c | 29 +++++++++++++++++++++++++++++
gobject/gproperty.c | 21 ++++-----------------
gobject/gtype-private.h | 5 +++++
3 files changed, 38 insertions(+), 17 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 2724075..991cbeb 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -4387,3 +4387,32 @@ g_weak_ref_set (GWeakRef *weak_ref,
g_rw_lock_writer_unlock (&weak_locations_lock);
}
+
+void
+_g_object_lock (gpointer object,
+ GQuark lock_id)
+{
+ gint *bit_lock_p;
+
+ bit_lock_p = g_object_get_qdata (object, lock_id);
+ if (bit_lock_p == NULL)
+ {
+ bit_lock_p = g_new (gint, 1);
+ g_object_set_qdata_full (object, lock_id, bit_lock_p, g_free);
+ }
+
+ g_bit_lock (bit_lock_p, 0);
+}
+
+void
+_g_object_unlock (gpointer object,
+ GQuark lock_id)
+{
+ gint *bit_lock_p;
+
+ bit_lock_p = g_object_get_qdata (object, lock_id);
+ if (bit_lock_p == NULL)
+ return;
+
+ g_bit_unlock (bit_lock_p, 0);
+}
diff --git a/gobject/gproperty.c b/gobject/gproperty.c
index 3cba304..4d52596 100644
--- a/gobject/gproperty.c
+++ b/gobject/gproperty.c
@@ -334,6 +334,7 @@
#include "gvaluecollector.h"
#include "gparam.h"
#include "gtype.h"
+#include "gtype-private.h"
#include "gvalue.h"
#include "gvaluetypes.h"
@@ -689,32 +690,18 @@ static void
g_property_default_lock (GProperty *property,
gpointer gobject)
{
- gpointer bit_lock_p;
-
g_property_ensure_prop_id (property);
- bit_lock_p = g_object_get_qdata (gobject, property->prop_id);
- if (bit_lock_p == NULL)
- {
- bit_lock_p = g_new0 (gint, 1);
- g_object_set_qdata_full (gobject, property->prop_id, bit_lock_p, g_free);
- }
-
- g_bit_lock (bit_lock_p, 0);
+ _g_object_lock (gobject, property->prop_id);
}
static void
g_property_default_unlock (GProperty *property,
gpointer gobject)
{
- gpointer bit_lock_p;
-
- bit_lock_p = g_object_get_qdata (gobject, property->prop_id);
- if (bit_lock_p == NULL)
- return;
+ g_property_ensure_prop_id (property);
- g_bit_unlock (bit_lock_p, 0);
- g_object_set_qdata (gobject, property->prop_id, NULL);
+ _g_object_unlock (gobject, property->prop_id);
}
static inline void
diff --git a/gobject/gtype-private.h b/gobject/gtype-private.h
index d9e31e4..7df904b 100644
--- a/gobject/gtype-private.h
+++ b/gobject/gtype-private.h
@@ -74,6 +74,11 @@ void _g_closure_invoke_va (GClosure *closure,
gboolean g_type_is_in_init (GType type);
+void _g_object_lock (gpointer object,
+ GQuark lock_id);
+void _g_object_unlock (gpointer object,
+ GQuark lock_id);
+
G_END_DECLS
#endif /* __G_TYPE_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]