[glib] glib/gpoll W32: use WFSOE() instead of SleepEx()



commit cb2316aaa1adc1f80498141d51467a850cde5fac
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Sat Jul 29 07:56:19 2017 +0000

    glib/gpoll W32: use WFSOE() instead of SleepEx()
    
    WaitForSingleObjectEx() is supposed to be a more efficient sleep method.
    It waits on the handle of the current process. That handle will be signaled once the process terminates, 
and since we're *inside* the process, it'll never happen (and if it does, we won't care anymore).
    The use of an alertable wait ensures that we wake up when a completion routine wants to run.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785468

 glib/gpoll.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/glib/gpoll.c b/glib/gpoll.c
index b6c83d8..694f1f9 100644
--- a/glib/gpoll.c
+++ b/glib/gpoll.c
@@ -164,10 +164,11 @@ poll_rest (gboolean  poll_msgs,
       if (timeout == INFINITE)
        ready = WAIT_FAILED;
       else
-       {
-         SleepEx (timeout, TRUE);
-         ready = WAIT_TIMEOUT;
-       }
+        {
+          /* Wait for the current process to die, more efficient than SleepEx(). */
+          WaitForSingleObjectEx (GetCurrentProcess (), timeout, TRUE);
+          ready = WAIT_TIMEOUT;
+        }
     }
   else
     {


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