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.
This commit is contained in:
Matthias Clasen
2011-09-18 20:04:28 -04:00
committed by Ryan Lortie
parent c4a69e784e
commit 0044763a71
4 changed files with 19 additions and 13 deletions

View File

@@ -1098,6 +1098,7 @@ g_thread_exit
g_thread_join g_thread_join
g_thread_self g_thread_self
g_thread_set_priority g_thread_set_priority
g_thread_yield
g_static_mutex_free g_static_mutex_free
g_static_mutex_get_mutex_impl g_static_mutex_get_mutex_impl
g_static_mutex_init g_static_mutex_init

View File

@@ -434,7 +434,7 @@ g_thread_create_posix_impl (GThreadFunc thread_func,
static void static void
g_thread_yield_posix_impl (void) g_thread_yield_posix_impl (void)
{ {
POSIX_YIELD_FUNC; sched_yield ();
} }
static void static void

View File

@@ -854,17 +854,7 @@ static GThreadFunctions g_thread_functions_for_glib_use_old = {
gboolean, gboolean, GThreadPriority, gboolean, gboolean, GThreadPriority,
gpointer, GError**))g_thread_fail, gpointer, GError**))g_thread_fail,
/** NULL, /* thread_yield */
* 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_join */ NULL, /* thread_join */
NULL, /* thread_exit */ NULL, /* thread_exit */
NULL, /* thread_set_priority */ NULL, /* thread_set_priority */
@@ -2169,6 +2159,21 @@ g_thread_self (void)
return (GThread*)thread; 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 ----------------------------------------------------- */ /* GStaticRWLock {{{1 ----------------------------------------------------- */
/** /**

View File

@@ -187,7 +187,6 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
#else #else
#define g_thread_supported() (g_threads_got_initialized) #define g_thread_supported() (g_threads_got_initialized)
#endif #endif
#define g_thread_yield() G_THREAD_CF (thread_yield, (void)0, ())
#define g_thread_create(func, data, joinable, error) \ #define g_thread_create(func, data, joinable, error) \
(g_thread_create_full (func, data, 0, joinable, FALSE, \ (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); GThread* g_thread_self (void);
void g_thread_exit (gpointer retval); void g_thread_exit (gpointer retval);
gpointer g_thread_join (GThread *thread); gpointer g_thread_join (GThread *thread);
void g_thread_yield (void);
void g_thread_set_priority (GThread *thread, void g_thread_set_priority (GThread *thread,
GThreadPriority priority); GThreadPriority priority);