mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
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:
parent
0f6098bf64
commit
6e9706bcbc
3 changed files with 11 additions and 3 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue