[glib] Clean up g_thread_yield implementation



commit 0044763a715ac5cec27fab5a7f247d3a1045d9aa
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 18 20:04:28 2011 -0400

    Clean up g_thread_yield implementation
    
    This was the last macro wrapper that was directly accessing the
    vtable. Make it a regular function, like the rest.

 glib/glib.symbols    |    1 +
 glib/gthread-posix.c |    2 +-
 glib/gthread.c       |   27 ++++++++++++++++-----------
 glib/gthread.h       |    2 +-
 4 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/glib/glib.symbols b/glib/glib.symbols
index 30fd422..7116518 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1098,6 +1098,7 @@ g_thread_exit
 g_thread_join
 g_thread_self
 g_thread_set_priority
+g_thread_yield
 g_static_mutex_free
 g_static_mutex_get_mutex_impl
 g_static_mutex_init
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index 237b8cb..10ef8ed 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -434,7 +434,7 @@ g_thread_create_posix_impl (GThreadFunc thread_func,
 static void
 g_thread_yield_posix_impl (void)
 {
-  POSIX_YIELD_FUNC;
+  sched_yield ();
 }
 
 static void
diff --git a/glib/gthread.c b/glib/gthread.c
index 3370eaa..5ed3e14 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -854,17 +854,7 @@ static GThreadFunctions g_thread_functions_for_glib_use_old = {
 	   gboolean, gboolean, GThreadPriority,
 	   gpointer, GError**))g_thread_fail,
 
-/**
- * g_thread_yield:
- *
- * Gives way to other threads waiting to be scheduled.
- *
- * This function is often used as a method to make busy wait less evil.
- * But in most cases you will encounter, there are better methods to do
- * that. So in general you shouldn't use this function.
- **/
-  NULL,
-
+  NULL,                                        /* thread_yield */
   NULL,                                        /* thread_join */
   NULL,                                        /* thread_exit */
   NULL,                                        /* thread_set_priority */
@@ -2169,6 +2159,21 @@ g_thread_self (void)
   return (GThread*)thread;
 }
 
+/**
+ * g_thread_yield:
+ *
+ * Gives way to other threads waiting to be scheduled.
+ *
+ * This function is often used as a method to make busy wait less evil.
+ * But in most cases you will encounter, there are better methods to do
+ * that. So in general you shouldn't use this function.
+ */
+void
+g_thread_yield (void)
+{
+  G_THREAD_UF (thread_yield, ());
+}
+
 /* GStaticRWLock {{{1 ----------------------------------------------------- */
 
 /**
diff --git a/glib/gthread.h b/glib/gthread.h
index e9d5ebe..6caaa1c 100644
--- a/glib/gthread.h
+++ b/glib/gthread.h
@@ -187,7 +187,6 @@ GMutex* g_static_mutex_get_mutex_impl   (GMutex **mutex);
 #else
 #define g_thread_supported()    (g_threads_got_initialized)
 #endif
-#define g_thread_yield()              G_THREAD_CF (thread_yield, (void)0, ())
 
 #define g_thread_create(func, data, joinable, error)			\
   (g_thread_create_full (func, data, 0, joinable, FALSE, 		\
@@ -203,6 +202,7 @@ GThread* g_thread_create_full  (GThreadFunc            func,
 GThread* g_thread_self         (void);
 void     g_thread_exit         (gpointer               retval);
 gpointer g_thread_join         (GThread               *thread);
+void     g_thread_yield        (void);
 
 void     g_thread_set_priority (GThread               *thread,
                                 GThreadPriority        priority);



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