mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 07:38:54 +02:00
signals: No need to use atomics for Handler refcount
handler_ref and handler_unref_R are always called with the signal lock held. This is obvious for handler_unref_R as it even sometimes drops this lock, and can be verified quickly for handler_ref by looking at all call sites. This improves the performace about 6% on the emit-handled and the emit-handled-generic tests. https://bugzilla.gnome.org/show_bug.cgi?id=694253
This commit is contained in:
@@ -596,7 +596,7 @@ handler_ref (Handler *handler)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (handler->ref_count > 0);
|
g_return_if_fail (handler->ref_count > 0);
|
||||||
|
|
||||||
g_atomic_int_inc ((int *)&handler->ref_count);
|
handler->ref_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -604,13 +604,11 @@ handler_unref_R (guint signal_id,
|
|||||||
gpointer instance,
|
gpointer instance,
|
||||||
Handler *handler)
|
Handler *handler)
|
||||||
{
|
{
|
||||||
gboolean is_zero;
|
|
||||||
|
|
||||||
g_return_if_fail (handler->ref_count > 0);
|
g_return_if_fail (handler->ref_count > 0);
|
||||||
|
|
||||||
is_zero = g_atomic_int_dec_and_test ((int *)&handler->ref_count);
|
|
||||||
|
|
||||||
if (G_UNLIKELY (is_zero))
|
handler->ref_count--;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (handler->ref_count == 0))
|
||||||
{
|
{
|
||||||
HandlerList *hlist = NULL;
|
HandlerList *hlist = NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user