diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-08-30 17:12:35 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-08-30 17:12:35 +0000 |
commit | 2f6cc4f8fa8d806ef6120887cd3aed62b1b072c0 (patch) | |
tree | 7a0c37b7b67c75a394945baa3f370ed69d3c4699 /src/pulsecore/thread-posix.c | |
parent | ad0535beef4cd0d4e96fa194d54796a0945ed3c6 (diff) | |
download | pulseaudio-2f6cc4f8fa8d806ef6120887cd3aed62b1b072c0.tar.gz |
fix handling of "running" variable
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1349 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/thread-posix.c')
-rw-r--r-- | src/pulsecore/thread-posix.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/pulsecore/thread-posix.c b/src/pulsecore/thread-posix.c index 54f21b75a..b634a6f6b 100644 --- a/src/pulsecore/thread-posix.c +++ b/src/pulsecore/thread-posix.c @@ -66,9 +66,9 @@ static void* internal_thread_func(void *userdata) { ASSERT_SUCCESS(pthread_once(&thread_tls_once, thread_tls_once_func)); pa_tls_set(thread_tls, t); - AO_store_release_write(&t->running, 1); + AO_fetch_and_add1_full(&t->running); t->thread_func(t->userdata); - AO_store_release_write(&t->running, 0); + AO_fetch_and_add_full(&t->running, (AO_t) -2); return NULL; } @@ -79,19 +79,24 @@ pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) { t = pa_xnew(pa_thread, 1); t->thread_func = thread_func; t->userdata = userdata; + AO_store_full(&t->running, 0); if (pthread_create(&t->id, NULL, internal_thread_func, t) < 0) { pa_xfree(t); return NULL; } + AO_fetch_and_add1_full(&t->running); + return t; } int pa_thread_is_running(pa_thread *t) { + AO_t r; assert(t); - return !!AO_load_acquire_read(&t->running); + r = AO_load_full(&t->running); + return r == 1 || r == 2; } void pa_thread_free(pa_thread *t) { |