From 5cac5c828b9d56ed0b1932deb7364d6ba926eb96 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 24 Sep 2009 14:57:19 +0200 Subject: [PATCH] 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 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gobject/gtype.c b/gobject/gtype.c index 412e9ccd7..d0f1c99be 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; }