Merge HUGE set of changes temporarily into a branch, to allow me to move them from...
[profile/ivi/pulseaudio-panda.git] / src / pulsecore / asyncq.h
1 #ifndef foopulseasyncqhfoo
2 #define foopulseasyncqhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of PulseAudio.
8
9   Copyright 2004-2006 Lennart Poettering
10
11   PulseAudio is free software; you can redistribute it and/or modify
12   it under the terms of the GNU Lesser General Public License as
13   published by the Free Software Foundation; either version 2.1 of the
14   License, or (at your option) any later version.
15
16   PulseAudio is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public
22   License along with PulseAudio; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24   USA.
25 ***/
26
27 #include <sys/types.h>
28 #include <pulse/def.h>
29
30 /* A simple, asynchronous, lock-free (if requested also wait-free)
31  * queue. Not multiple-reader/multiple-writer safe. If that is
32  * required both sides can be protected by a mutex each. --- Which is
33  * not a bad thing in most cases, since this queue is intended for
34  * communication between a normal thread and a single real-time
35  * thread. Only the real-time side needs to be lock-free/wait-free.
36  *
37  * If the queue is full and another entry shall be pushed, or when the
38  * queue is empty and another entry shall be popped and the "wait"
39  * argument is non-zero, the queue will block on a UNIX FIFO object --
40  * that will probably require locking on the kernel side -- which
41  * however is probably not problematic, because we do it only on
42  * starvation or overload in which case we have to block anyway.  */
43
44 typedef struct pa_asyncq pa_asyncq;
45
46 pa_asyncq* pa_asyncq_new(size_t size);
47 void pa_asyncq_free(pa_asyncq* q, pa_free_cb_t free_cb);
48
49 void* pa_asyncq_pop(pa_asyncq *q, int wait);
50 int pa_asyncq_push(pa_asyncq *q, void *p, int wait);
51
52 int pa_asyncq_get_fd(pa_asyncq *q);
53 int pa_asyncq_before_poll(pa_asyncq *a);
54 int pa_asyncq_after_poll(pa_asyncq *a);
55
56 #endif