pa_thread_func_t thread_func;
void *userdata;
pa_atomic_t running;
+ pa_bool_t joined;
};
struct pa_tls {
t = pa_xnew(pa_thread, 1);
t->thread_func = thread_func;
t->userdata = userdata;
+ t->joined = FALSE;
pa_atomic_store(&t->running, 0);
if (pthread_create(&t->id, NULL, internal_thread_func, t) < 0) {
int pa_thread_join(pa_thread *t) {
pa_assert(t);
+ pa_assert(t->thread_func);
+
+ if (t->joined)
+ return -1;
+ t->joined = TRUE;
return pthread_join(t->id, NULL);
}
t->id = pthread_self();
t->thread_func = NULL;
t->userdata = NULL;
+ t->joined = TRUE;
pa_atomic_store(&t->running, 2);
PA_STATIC_TLS_SET(current_thread, t);
pa_assert_se(pthread_setspecific(t->key, userdata) == 0);
return r;
}
-