A generic FIFO queue.
More...
#include <stdlib.h>
#include <stdint.h>
Go to the source code of this file.
|
| struct | queue_NAME |
| | instance type generated by QUEUE with name set to NAME, type set to TYPE, and size set to SIZE More...
|
| |
|
| #define | QUEUE(name, type, size) |
| | Generates the queue api. More...
|
| |
◆ QUEUE
| #define QUEUE |
( |
|
name, |
|
|
|
type, |
|
|
|
size |
|
) |
| |
Generates the queue api.
- Parameters
-
| name | a name for the api with the given type and size |
| type | the type of data to store in the queue |
| size | the max number of data elements |
◆ queue_NAME_count()
| size_t queue_NAME_count |
( |
const volatile struct queue_NAME * |
self | ) |
|
|
inlinestatic |
get the number of items in the queue
- Parameters
-
| self | the queue_NAME from which to get the item count |
- Returns
- the item count
◆ queue_NAME_foreach()
| void queue_NAME_foreach |
( |
volatile struct queue_NAME * |
self, |
|
|
int(*)(volatile TYPE *, volatile void *) |
fun, |
|
|
volatile void * |
ctx |
|
) |
| |
|
inlinestatic |
calls fun for each item in the queue
- Parameters
-
| self | the queue to traverse |
| fun | a function pointer that takes a pointer to TYPE and a pointer to void
if fun returns 0 then the traversal will continue otherwise it will stop |
| ctx | a pointer to arbitrary context that gets passed as the second argument to fun for each item in the queue |
◆ queue_NAME_init()
| int queue_NAME_init |
( |
volatile struct queue_NAME * |
self | ) |
|
|
inlinestatic |
init function generated by QUEUE with name set to NAME, type set to TYPE, and size set to SIZE
- Parameters
-
- Returns
- 0 if successful
◆ queue_NAME_pop()
| int queue_NAME_pop |
( |
volatile struct queue_NAME * |
self, |
|
|
volatile TYPE * |
item |
|
) |
| |
|
inlinestatic |
pop an item from the queue
- Parameters
-
| self | the queue_NAME from which to pop the item |
| item | pointer the location to which the item should be copied |
- Returns
- 0 if successful
◆ queue_NAME_push()
| int queue_NAME_push |
( |
volatile struct queue_NAME * |
self, |
|
|
const volatile TYPE * |
item |
|
) |
| |
|
inlinestatic |
push an item onto the queue
- Parameters
-
| self | the queue_NAME on which to push the item |
| item | pointer to the item to push |
- Returns
- 0 if successful