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, see <http://www.gnu.org/licenses/>.
21***/
22
23#include <sys/types.h>
24
25/* A simple, asynchronous semaphore which uses fds for sleeping. In
26 * the best case all functions are lock-free unless sleeping is
27 * required.  */
28
29#include <pulsecore/atomic.h>
30
31typedef struct pa_fdsem pa_fdsem;
32
33typedef 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
39pa_fdsem *pa_fdsem_new(void);
40pa_fdsem *pa_fdsem_open_shm(pa_fdsem_data *data, int event_fd);
41pa_fdsem *pa_fdsem_new_shm(pa_fdsem_data *data);
42void pa_fdsem_free(pa_fdsem *f);
43
44void pa_fdsem_post(pa_fdsem *f);
45void pa_fdsem_wait(pa_fdsem *f);
46int pa_fdsem_try(pa_fdsem *f);
47
48int pa_fdsem_get(pa_fdsem *f);
49
50int pa_fdsem_before_poll(pa_fdsem *f);
51int pa_fdsem_after_poll(pa_fdsem *f);
52
53#endif
54