]> code.delx.au - pulseaudio/commitdiff
Also wrap yield functionality so that it can be platform independent.
authorPierre Ossman <ossman@cendio.se>
Thu, 31 Aug 2006 16:13:07 +0000 (16:13 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 31 Aug 2006 16:13:07 +0000 (16:13 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1353 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulsecore/thread-posix.c
src/pulsecore/thread.h
src/tests/thread-test.c

index 6ca46d7057d94170ba32e7abc69ee5dec617ba6b..4c12ec93b14334ff02e51ba320807fad7298462a 100644 (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;
 
index 978e992763ba98d377abc5a4d6eacdbe8e8a5dcb..9b99c8c24fa923eea55d29caba2366eabbc12aac 100644 (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;
 
index a93ac1e4ae632398cf3ae7b4582f0f1b02fa6770..120d25542ee8cc17e507e9bbc29edb4f382a6a82 100644 (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);
     }