return pa_tls_get(thread_tls);
}
+void* pa_thread_get_data(pa_thread *t) {
+ pa_assert(t);
+
+ return t->userdata;
+}
+
+void pa_thread_set_data(pa_thread *t, void *userdata) {
+ pa_assert(t);
+
+ t->userdata = userdata;
+}
+
+void pa_thread_set_name(pa_thread *t, const char *name) {
+ /* Not implemented */
+}
+
+const char *pa_thread_get_name(pa_thread *t) {
+ /* Not implemented */
+ return NULL;
+}
+
void pa_thread_yield(void) {
Sleep(0);
}
#include <config.h>
#endif
+#ifdef HAVE_PTHREAD
#include <pthread.h>
+#endif
#include <pulsecore/thread.h>
#include <pulsecore/once.h>
static pa_once once = PA_ONCE_INIT;
static volatile unsigned n_run = 0;
static const char * volatile ran_by = NULL;
+#ifdef HAVE_PTHREAD
static pthread_barrier_t barrier;
+#endif
static unsigned n_cpu;
#define N_ITERATIONS 500
}
static void thread_func(void *data) {
+#ifdef HAVE_PTHREAD
int r;
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
r = pthread_barrier_wait(&barrier);
pa_assert(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD);
+#endif /* HAVE_PTHREAD */
pa_run_once(&once, once_func);
}
for (n = 0; n < N_ITERATIONS; n++) {
pa_thread* threads[N_THREADS];
+#ifdef HAVE_PTHREAD
pa_assert_se(pthread_barrier_init(&barrier, NULL, N_THREADS) == 0);
+#endif
/* Yes, kinda ugly */
pa_zero(once);
n_run = 0;
ran_by = NULL;
+#ifdef HAVE_PTHREAD
pa_assert_se(pthread_barrier_destroy(&barrier) == 0);
+#endif
}
return 0;
int i, k;
pa_thread* t[THREADS_MAX];
- assert(pa_thread_is_running(pa_thread_self()));
-
mutex = pa_mutex_new(FALSE, FALSE);
cond1 = pa_cond_new();
cond2 = pa_cond_new();