4 This file is part of PulseAudio.
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30 #include <pulse/util.h>
31 #include <pulse/xmalloc.h>
32 #include <pulsecore/asyncq.h>
33 #include <pulsecore/thread.h>
34 #include <pulsecore/log.h>
35 #include <pulsecore/core-util.h>
36 #include <pulsecore/macro.h>
38 static void producer(void *_q
) {
42 for (i
= 0; i
< 1000; i
++) {
43 printf("pushing %i\n", i
);
44 pa_asyncq_push(q
, PA_UINT_TO_PTR(i
+1), 1);
47 pa_asyncq_push(q
, PA_UINT_TO_PTR(-1), 1);
48 printf("pushed end\n");
51 static void consumer(void *_q
) {
59 p
= pa_asyncq_pop(q
, 1);
61 if (p
== PA_UINT_TO_PTR(-1))
64 pa_assert(p
== PA_UINT_TO_PTR(i
+1));
66 printf("popped %i\n", i
);
69 printf("popped end\n");
72 int main(int argc
, char *argv
[]) {
76 pa_assert_se(q
= pa_asyncq_new(0));
78 pa_assert_se(t1
= pa_thread_new(producer
, q
));
79 pa_assert_se(t2
= pa_thread_new(consumer
, q
));
84 pa_asyncq_free(q
, NULL
);