diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-11-01 21:10:26 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-11-01 21:10:26 +0100 |
commit | 58b53bbc1adb62f2a55e1654f97f90df7518f7fd (patch) | |
tree | 3fdd07398cc4dbd5c33b49da46f79c6d74d7e8ce /src/pulsecore/once.c | |
parent | adc2973c8dfab862d4333e0c1206995cd2df20c6 (diff) |
a bit of pa_bool_t'ization
Diffstat (limited to 'src/pulsecore/once.c')
-rw-r--r-- | src/pulsecore/once.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pulsecore/once.c b/src/pulsecore/once.c index 989741dc..3d4543cb 100644 --- a/src/pulsecore/once.c +++ b/src/pulsecore/once.c @@ -28,13 +28,13 @@ #include "once.h" -int pa_once_begin(pa_once *control) { +pa_bool_t pa_once_begin(pa_once *control) { pa_mutex *m; pa_assert(control); if (pa_atomic_load(&control->done)) - return 0; + return FALSE; pa_atomic_inc(&control->ref); @@ -50,15 +50,17 @@ int pa_once_begin(pa_once *control) { * wait until it is unlocked */ pa_mutex_lock(m); + pa_assert(pa_atomic_load(&control->done)); + pa_once_end(control); - return 0; + return FALSE; } pa_assert_se(m = pa_mutex_new(FALSE, FALSE)); pa_mutex_lock(m); if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m)) - return 1; + return TRUE; pa_mutex_unlock(m); pa_mutex_free(m); @@ -91,4 +93,3 @@ void pa_run_once(pa_once *control, pa_once_func_t func) { pa_once_end(control); } } - |