type_data_unref_Wm => type_data_unref_U

Make the type unref function not hold any locks when called. This
makes it easier to optimize it to be atomic later.

https://bugzilla.gnome.org/show_bug.cgi?id=585375
This commit is contained in:
Edward Hervey 2009-09-24 11:19:58 +02:00 committed by Alexander Larsson
parent b163759320
commit 2ec989902b

View File

@ -185,7 +185,7 @@ static void type_data_make_W (TypeNode *node,
const GTypeInfo *info, const GTypeInfo *info,
const GTypeValueTable *value_table); const GTypeValueTable *value_table);
static inline void type_data_ref_Wm (TypeNode *node); static inline void type_data_ref_Wm (TypeNode *node);
static inline void type_data_unref_WmREC (TypeNode *node, static inline void type_data_unref_U (TypeNode *node,
gboolean uncached); gboolean uncached);
static void type_data_last_unref_Wm (TypeNode * node, static void type_data_last_unref_Wm (TypeNode * node,
gboolean uncached); gboolean uncached);
@ -1680,9 +1680,8 @@ type_iface_blow_holder_info_Wm (TypeNode *iface,
G_WRITE_UNLOCK (&type_rw_lock); G_WRITE_UNLOCK (&type_rw_lock);
g_type_plugin_unuse (iholder->plugin); g_type_plugin_unuse (iholder->plugin);
type_data_unref_U (iface, FALSE);
G_WRITE_LOCK (&type_rw_lock); G_WRITE_LOCK (&type_rw_lock);
type_data_unref_WmREC (iface, FALSE);
} }
} }
@ -2338,16 +2337,17 @@ type_data_last_unref_Wm (TypeNode *node,
G_WRITE_UNLOCK (&type_rw_lock); G_WRITE_UNLOCK (&type_rw_lock);
g_type_plugin_unuse (node->plugin); g_type_plugin_unuse (node->plugin);
G_WRITE_LOCK (&type_rw_lock);
if (ptype) if (ptype)
type_data_unref_WmREC (lookup_type_node_I (ptype), FALSE); type_data_unref_U (lookup_type_node_I (ptype), FALSE);
G_WRITE_LOCK (&type_rw_lock);
} }
} }
static inline void static inline void
type_data_unref_WmREC (TypeNode *node, type_data_unref_U (TypeNode *node,
gboolean uncached) gboolean uncached)
{ {
G_WRITE_LOCK (&type_rw_lock);
g_assert (node->data && NODE_REFCOUNT (node) > 0); g_assert (node->data && NODE_REFCOUNT (node) > 0);
if (NODE_REFCOUNT (node) > 1) if (NODE_REFCOUNT (node) > 1)
node->ref_count -= 1; node->ref_count -= 1;
@ -2365,6 +2365,7 @@ type_data_unref_WmREC (TypeNode *node,
type_data_last_unref_Wm (node, uncached); type_data_last_unref_Wm (node, uncached);
g_static_rec_mutex_unlock (&class_init_rec_mutex); g_static_rec_mutex_unlock (&class_init_rec_mutex);
} }
G_WRITE_UNLOCK (&type_rw_lock);
} }
/** /**
@ -2876,14 +2877,11 @@ g_type_class_unref (gpointer g_class)
g_return_if_fail (g_class != NULL); g_return_if_fail (g_class != NULL);
node = lookup_type_node_I (class->g_type); node = lookup_type_node_I (class->g_type);
G_WRITE_LOCK (&type_rw_lock); if (node && node->is_classed && NODE_REFCOUNT (node))
if (node && node->is_classed && node->data && type_data_unref_U (node, FALSE);
node->data->class.class == class && NODE_REFCOUNT (node) > 0)
type_data_unref_WmREC (node, FALSE);
else else
g_warning ("cannot unreference class of invalid (unclassed) type `%s'", g_warning ("cannot unreference class of invalid (unclassed) type `%s'",
type_descriptive_name_I (class->g_type)); type_descriptive_name_I (class->g_type));
G_WRITE_UNLOCK (&type_rw_lock);
} }
/** /**
@ -2903,15 +2901,12 @@ g_type_class_unref_uncached (gpointer g_class)
g_return_if_fail (g_class != NULL); g_return_if_fail (g_class != NULL);
G_WRITE_LOCK (&type_rw_lock);
node = lookup_type_node_I (class->g_type); node = lookup_type_node_I (class->g_type);
if (node && node->is_classed && node->data && if (node && node->is_classed && NODE_REFCOUNT (node))
node->data->class.class == class && NODE_REFCOUNT (node) > 0) type_data_unref_U (node, TRUE);
type_data_unref_WmREC (node, TRUE);
else else
g_warning ("cannot unreference class of invalid (unclassed) type `%s'", g_warning ("cannot unreference class of invalid (unclassed) type `%s'",
type_descriptive_name_I (class->g_type)); type_descriptive_name_I (class->g_type));
G_WRITE_UNLOCK (&type_rw_lock);
} }
/** /**
@ -3192,15 +3187,11 @@ g_type_default_interface_unref (gpointer g_iface)
g_return_if_fail (g_iface != NULL); g_return_if_fail (g_iface != NULL);
node = lookup_type_node_I (vtable->g_type); node = lookup_type_node_I (vtable->g_type);
G_WRITE_LOCK (&type_rw_lock); if (node && NODE_IS_IFACE (node))
if (node && NODE_IS_IFACE (node) && type_data_unref_U (node, FALSE);
node->data->iface.dflt_vtable == g_iface &&
NODE_REFCOUNT (node) > 0)
type_data_unref_WmREC (node, FALSE);
else else
g_warning ("cannot unreference invalid interface default vtable for '%s'", g_warning ("cannot unreference invalid interface default vtable for '%s'",
type_descriptive_name_I (vtable->g_type)); type_descriptive_name_I (vtable->g_type));
G_WRITE_UNLOCK (&type_rw_lock);
} }
/** /**