mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-11 13:30:02 -05:00
make pa_thread_self() return a sensible pointer on foreign threads
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1368 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
6db6c835ec
commit
8e7c2a3b0c
1 changed files with 19 additions and 2 deletions
|
|
@ -117,15 +117,32 @@ int pa_thread_join(pa_thread *t) {
|
|||
}
|
||||
|
||||
pa_thread* pa_thread_self(void) {
|
||||
pa_thread *t;
|
||||
|
||||
ASSERT_SUCCESS(pthread_once(&thread_tls_once, thread_tls_once_func));
|
||||
return pa_tls_get(thread_tls);
|
||||
|
||||
if ((t = pa_tls_get(thread_tls)))
|
||||
return t;
|
||||
|
||||
/* This is a foreign thread, let's create a pthread structure to
|
||||
* make sure that we can always return a sensible pointer */
|
||||
|
||||
t = pa_xnew(pa_thread, 1);
|
||||
t->id = pthread_self();
|
||||
t->thread_func = NULL;
|
||||
t->userdata = NULL;
|
||||
AO_store_full(&t->running, 1);
|
||||
|
||||
pa_tls_set(thread_tls, t);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void pa_thread_yield(void) {
|
||||
#ifdef HAVE_PTHREAD_YIELD
|
||||
pthread_yield();
|
||||
#else
|
||||
sched_yield();
|
||||
ASSERT_SUCCESS(sched_yield());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue