[glib/gobject-performance] Make g_type_class_peek[_static]() not take any locks
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gobject-performance] Make g_type_class_peek[_static]() not take any locks
- Date: Thu, 24 Sep 2009 13:10:28 +0000 (UTC)
commit f4536ff8e88f1da2a6ea7132f18d1278a090e419
Author: Benjamin Otte <otte gnome org>
Date: Thu Sep 24 14:57:19 2009 +0200
Make g_type_class_peek[_static]() not take any locks
By replacing a check for node->data with a check for NODE_REFCOUNT(node)
these functions don't require a read lock anymore.
gobject/gtype.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index c4840bc..ef2cc99 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -2954,14 +2954,12 @@ g_type_class_peek (GType type)
gpointer class;
node = lookup_type_node_I (type);
- G_READ_LOCK (&type_rw_lock);
- if (node && node->is_classed && node->data &&
+ if (node && node->is_classed && NODE_REFCOUNT (node) > 0 &&
g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
/* ref_count _may_ be 0 */
class = node->data->class.class;
else
class = NULL;
- G_READ_UNLOCK (&type_rw_lock);
return class;
}
@@ -2984,15 +2982,13 @@ g_type_class_peek_static (GType type)
gpointer class;
node = lookup_type_node_I (type);
- G_READ_LOCK (&type_rw_lock);
- if (node && node->is_classed && node->data &&
+ if (node && node->is_classed && NODE_REFCOUNT (node) &&
/* peek only static types: */ node->plugin == NULL &&
g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
/* ref_count _may_ be 0 */
class = node->data->class.class;
else
class = NULL;
- G_READ_UNLOCK (&type_rw_lock);
return class;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]