]> code.delx.au - pulseaudio/blob - src/pulsecore/fdsem.h
a434ac3be3eae3730078690e87d1252d8f1c0831
[pulseaudio] / src / pulsecore / fdsem.h
1 #ifndef foopulsefdsemhfoo
2 #define foopulsefdsemhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
13
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <sys/types.h>
26
27 /* A simple, asynchronous semaphore which uses fds for sleeping. In
28 * the best case all functions are lock-free unless sleeping is
29 * required. */
30
31 typedef struct pa_fdsem pa_fdsem;
32
33 typedef struct pa_fdsem_data {
34 pa_atomic_t waiting;
35 pa_atomic_t signalled;
36 pa_atomic_t in_pipe;
37 } pa_fdsem_data;
38
39 pa_fdsem *pa_fdsem_new(void);
40 pa_fdsem *pa_fdsem_open_shm(pa_fdsem_data *data, int event_fd);
41 pa_fdsem *pa_fdsem_new_shm(pa_fdsem_data *data, int* event_fd);
42 void pa_fdsem_free(pa_fdsem *f);
43
44 void pa_fdsem_post(pa_fdsem *f);
45 void pa_fdsem_wait(pa_fdsem *f);
46 int pa_fdsem_try(pa_fdsem *f);
47
48 int pa_fdsem_get(pa_fdsem *f);
49
50 int pa_fdsem_before_poll(pa_fdsem *f);
51 int pa_fdsem_after_poll(pa_fdsem *f);
52
53 #endif