Also wrap yield functionality so that it can be platform independent.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1353 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Pierre Ossman 2006-08-31 16:13:07 +00:00
parent 0f6098bf64
commit 6e9706bcbc
3 changed files with 11 additions and 3 deletions

View file

@ -25,6 +25,7 @@
#include <assert.h>
#include <pthread.h>
#include <sched.h>
#include <atomic_ops.h>
@ -116,6 +117,14 @@ pa_thread* pa_thread_self(void) {
return pa_tls_get(thread_tls);
}
void pa_thread_yield(void) {
#ifdef HAVE_PTHREAD_YIELD
pthread_yield();
#else
sched_yield();
#endif
}
pa_tls* pa_tls_new(pa_free_cb_t free_cb) {
pa_tls *t;

View file

@ -33,6 +33,7 @@ void pa_thread_free(pa_thread *t);
int pa_thread_join(pa_thread *t);
int pa_thread_is_running(pa_thread *t);
pa_thread *pa_thread_self(void);
void pa_thread_yield(void);
typedef struct pa_tls pa_tls;

View file

@ -23,8 +23,6 @@
#include <config.h>
#endif
#include <sched.h>
#include <pulsecore/thread.h>
#include <pulsecore/mutex.h>
#include <pulsecore/log.h>
@ -73,7 +71,7 @@ static void thread_func(void *data) {
/* Spin! */
for (n = 0; n < k; n++)
sched_yield();
pa_thread_yield();
pa_mutex_lock(mutex);
}