[glib] Do not wake up main loop if change is from same thread



commit e4ee3079c5afc3c1c3d2415f20c3e8605728f074
Author: Frediano Ziglio <fziglio redhat com>
Date:   Mon Jan 25 14:59:24 2016 +0000

    Do not wake up main loop if change is from same thread
    
    This reduce the frequency the loop is waked up adding and removing
    file descriptors or timeouts.
    Considering that to support recursion events are removed from list and
    added again this reduce iteration number a lot.
    
    Signed-off-by: Frediano Ziglio <fziglio redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761102

 glib/gmain.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 68522b0..3db6432 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -1837,7 +1837,8 @@ g_source_set_ready_time (GSource *source,
     {
       /* Quite likely that we need to change the timeout on the poll */
       if (!SOURCE_BLOCKED (source))
-        g_wakeup_signal (context->wakeup);
+        if (context->owner && context->owner != G_THREAD_SELF)
+          g_wakeup_signal (context->wakeup);
       UNLOCK_CONTEXT (context);
     }
 }
@@ -4342,7 +4343,8 @@ g_main_context_add_poll_unlocked (GMainContext *context,
   context->poll_changed = TRUE;
 
   /* Now wake up the main loop if it is waiting in the poll() */
-  g_wakeup_signal (context->wakeup);
+  if (context->owner && context->owner != G_THREAD_SELF)
+    g_wakeup_signal (context->wakeup);
 }
 
 /**
@@ -4402,7 +4404,8 @@ g_main_context_remove_poll_unlocked (GMainContext *context,
   context->poll_changed = TRUE;
   
   /* Now wake up the main loop if it is waiting in the poll() */
-  g_wakeup_signal (context->wakeup);
+  if (context->owner && context->owner != G_THREAD_SELF)
+    g_wakeup_signal (context->wakeup);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]