mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01: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:
parent
5bbca5fa0c
commit
3e274423ba
@ -596,7 +596,7 @@ handler_ref (Handler *handler)
|
||||
{
|
||||
g_return_if_fail (handler->ref_count > 0);
|
||||
|
||||
g_atomic_int_inc ((int *)&handler->ref_count);
|
||||
handler->ref_count++;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -604,13 +604,11 @@ handler_unref_R (guint signal_id,
|
||||
gpointer instance,
|
||||
Handler *handler)
|
||||
{
|
||||
gboolean is_zero;
|
||||
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user