Merge ../mlt
[melted] / src / modules / jackrack / lock_free_fifo.h
1 /*
2 * JACK Rack
3 *
4 * Original:
5 * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net)
6 *
7 * Modification for MLT:
8 * Copyright (C) 2004 Ushodaya Enterprises Limited
9 * Author: Dan Dennedy <dan@dennedy.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 #ifndef __JLH_LOCK_FREE_FIFO_H__
27 #define __JLH_LOCK_FREE_FIFO_H__
28
29 /** lock free fifo ring buffer structure */
30 typedef struct lock_free_fifo {
31 /** Size of the ringbuffer (in elements) */
32 unsigned int size;
33 /** the memory containing the ringbuffer */
34 void * data;
35 /** the size of an element */
36 size_t object_size;
37 /** the current position of the reader */
38 unsigned int read_index;
39 /** the current position of the writer */
40 unsigned int write_index;
41 } lff_t;
42
43 void lff_init (lff_t * lff, unsigned int size, size_t object_size);
44 void lff_free (lff_t * lff);
45
46 lff_t * lff_new (unsigned int size, size_t object_size);
47 void lff_destroy (lff_t * lock_free_fifo);
48
49 int lff_read (lff_t * lock_free_fifo, void * data);
50 int lff_write (lff_t * lock_free_fifo, void * data);
51
52
53 #endif /* __JLH_LOCK_FREE_FIFO_H__ */