4 * Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JLH_LOCK_FREE_FIFO_H__
22 #define __JLH_LOCK_FREE_FIFO_H__
24 /** lock free fifo ring buffer structure */
25 typedef struct lock_free_fifo
{
26 /** Size of the ringbuffer (in elements) */
28 /** the memory containing the ringbuffer */
30 /** the size of an element */
32 /** the current position of the reader */
33 unsigned int read_index
;
34 /** the current position of the writer */
35 unsigned int write_index
;
38 void lff_init (lff_t
* lff
, unsigned int size
, size_t object_size
);
39 void lff_free (lff_t
* lff
);
41 lff_t
* lff_new (unsigned int size
, size_t object_size
);
42 void lff_destroy (lff_t
* lock_free_fifo
);
44 int lff_read (lff_t
* lock_free_fifo
, void * data
);
45 int lff_write (lff_t
* lock_free_fifo
, void * data
);
48 #endif /* __JLH_LOCK_FREE_FIFO_H__ */