mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-08 13:29:59 -05:00
speed up semaphore allocation with an flist
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1909 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
008c709900
commit
107f12ae3c
1 changed files with 14 additions and 7 deletions
|
|
@ -40,6 +40,7 @@
|
||||||
#include "asyncmsgq.h"
|
#include "asyncmsgq.h"
|
||||||
|
|
||||||
PA_STATIC_FLIST_DECLARE(asyncmsgq, 0, pa_xfree);
|
PA_STATIC_FLIST_DECLARE(asyncmsgq, 0, pa_xfree);
|
||||||
|
PA_STATIC_FLIST_DECLARE(semaphores, 0, (void(*)(void*)) pa_semaphore_free);
|
||||||
|
|
||||||
struct asyncmsgq_item {
|
struct asyncmsgq_item {
|
||||||
int code;
|
int code;
|
||||||
|
|
@ -154,7 +155,11 @@ int pa_asyncmsgq_send(pa_asyncmsgq *a, pa_msgobject *object, int code, const voi
|
||||||
i.memchunk = *chunk;
|
i.memchunk = *chunk;
|
||||||
} else
|
} else
|
||||||
pa_memchunk_reset(&i.memchunk);
|
pa_memchunk_reset(&i.memchunk);
|
||||||
pa_assert_se(i.semaphore = pa_semaphore_new(0));
|
|
||||||
|
if (!(i.semaphore = pa_flist_pop(PA_STATIC_FLIST_GET(semaphores))))
|
||||||
|
i.semaphore = pa_semaphore_new(0);
|
||||||
|
|
||||||
|
pa_assert_se(i.semaphore);
|
||||||
|
|
||||||
/* Thus mutex makes the queue multiple-writer safe. This lock is only used on the writing side */
|
/* Thus mutex makes the queue multiple-writer safe. This lock is only used on the writing side */
|
||||||
pa_mutex_lock(a->mutex);
|
pa_mutex_lock(a->mutex);
|
||||||
|
|
@ -162,6 +167,8 @@ int pa_asyncmsgq_send(pa_asyncmsgq *a, pa_msgobject *object, int code, const voi
|
||||||
pa_mutex_unlock(a->mutex);
|
pa_mutex_unlock(a->mutex);
|
||||||
|
|
||||||
pa_semaphore_wait(i.semaphore);
|
pa_semaphore_wait(i.semaphore);
|
||||||
|
|
||||||
|
if (pa_flist_push(PA_STATIC_FLIST_GET(semaphores), i.semaphore) < 0)
|
||||||
pa_semaphore_free(i.semaphore);
|
pa_semaphore_free(i.semaphore);
|
||||||
|
|
||||||
return i.ret;
|
return i.ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue