8.3. fifo
— First In First Out queuing¶
Source code: src/collections/fifo.h
Test code: tst/collections/fifo/main.c
Defines
-
FIFO_DEFINE_TEMPLATE
(type)¶ Define the fifo structure and functions for a given type.
FIFO_DEFINE_TEMPLATE(int); int foo() { struct fifo_int_t fifo; int buf[4]; int value; fifo_init_int(&fifo, buf, membersof(buf)); // Put a value into the fifo. value = 10; fifo_put_int(&fifo, &value); // Get the value from the fifo. fifo_get_int(&fifo, &value); // Prints 'value = 10'. std_printf(FSTR("value= %d\r\n", value)); }
- Parameters
type
: Type of the elements in the defined fifo.
Functions
-
static int
fifo_init
(struct fifo_t *self_p, int max)¶ Initialize given fifo.
- Return
- zero(0) or negative error code.
- Parameters
self_p
: Fifo to initialize.max
: Maximum number of elements in the fifo.
- struct
- #include <fifo.h>