Clean up g_thread_yield implementation
authorMatthias Clasen <mclasen@redhat.com>
Mon, 19 Sep 2011 00:04:28 +0000 (20:04 -0400)
committerRyan Lortie <desrt@desrt.ca>
Wed, 21 Sep 2011 20:06:54 +0000 (16:06 -0400)
This was the last macro wrapper that was directly accessing the
vtable. Make it a regular function, like the rest.

glib/glib.symbols
glib/gthread-posix.c
glib/gthread.c
glib/gthread.h

index 30fd422..7116518 100644 (file)
@@ -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
index 237b8cb..10ef8ed 100644 (file)
@@ -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
index 3370eaa..5ed3e14 100644 (file)
@@ -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 ----------------------------------------------------- */
 
 /**
index e9d5ebe..6caaa1c 100644 (file)
@@ -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);