[glib] Make g_type_class_peek[_static]() not take any locks
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Make g_type_class_peek[_static]() not take any locks
- Date: Mon, 30 Nov 2009 20:04:03 +0000 (UTC)
commit 5cac5c828b9d56ed0b1932deb7364d6ba926eb96
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 412e9cc..d0f1c99 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -2950,14 +2950,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;
}
@@ -2980,15 +2978,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]