[pulseaudio-commits] r1353 - in /trunk/src: pulsecore/thread-posix.c pulsecore/thread.h tests/thread-test.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Aug 31 09:13:08 PDT 2006


Author: ossman
Date: Thu Aug 31 18:13:07 2006
New Revision: 1353

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1353&root=pulseaudio&view=rev
Log:
Also wrap yield functionality so that it can be platform independent.

Modified:
    trunk/src/pulsecore/thread-posix.c
    trunk/src/pulsecore/thread.h
    trunk/src/tests/thread-test.c

Modified: trunk/src/pulsecore/thread-posix.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/thread-posix.c?rev=1353&root=pulseaudio&r1=1352&r2=1353&view=diff
==============================================================================
--- trunk/src/pulsecore/thread-posix.c (original)
+++ trunk/src/pulsecore/thread-posix.c Thu Aug 31 18:13:07 2006
@@ -25,6 +25,7 @@
 
 #include <assert.h>
 #include <pthread.h>
+#include <sched.h>
 
 #include <atomic_ops.h>
 
@@ -116,6 +117,14 @@
     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;
 

Modified: trunk/src/pulsecore/thread.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/thread.h?rev=1353&root=pulseaudio&r1=1352&r2=1353&view=diff
==============================================================================
--- trunk/src/pulsecore/thread.h (original)
+++ trunk/src/pulsecore/thread.h Thu Aug 31 18:13:07 2006
@@ -33,6 +33,7 @@
 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;
 

Modified: trunk/src/tests/thread-test.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/tests/thread-test.c?rev=1353&root=pulseaudio&r1=1352&r2=1353&view=diff
==============================================================================
--- trunk/src/tests/thread-test.c (original)
+++ trunk/src/tests/thread-test.c Thu Aug 31 18:13:07 2006
@@ -22,8 +22,6 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
-#include <sched.h>
 
 #include <pulsecore/thread.h>
 #include <pulsecore/mutex.h>
@@ -73,7 +71,7 @@
         
         /* Spin! */
         for (n = 0; n < k; n++)
-            sched_yield();
+            pa_thread_yield();
         
         pa_mutex_lock(mutex);
     }




More information about the pulseaudio-commits mailing list