Non-thread-safe fifo (FIFO) implementation.
More...
#include <string.h>
#include <freeradius-devel/util/fifo.h>
Go to the source code of this file.
Non-thread-safe fifo (FIFO) implementation.
- Copyright
- 2005,2006 The FreeRADIUS server project
-
2005 Alan DeKok (aland.nosp@m.@fre.nosp@m.eradi.nosp@m.us.o.nosp@m.rg)
Definition in file fifo.c.
◆ fr_fifo_s
Definition at line 30 of file fifo.c.
Data Fields |
void * |
data[1] |
|
unsigned int |
first |
|
fr_fifo_free_t |
free_node |
Function to call to free nodes when the fifo is freed. |
unsigned int |
last |
Head and tail indexes for the fifo. |
unsigned int |
max |
How many elements were created in the fifo. |
unsigned int |
num |
How many elements exist in the fifo. |
char const * |
type |
Type of elements. |
◆ _fifo_free()
Free a fifo and optionally, any data still enqueued.
- Parameters
-
- Returns
- 0
Definition at line 46 of file fifo.c.
◆ _fr_fifo_create()
Create a fifo queue.
The first element enqueued will be the first to be dequeued.
- Note
- The created fifo does not provide any thread synchronisation functionality such as mutexes. If multiple threads are enqueueing and dequeueing data the callers must synchronise their access.
- Parameters
-
[in] | ctx | to allocate fifo array in. |
[in] | type | Talloc type of elements (may be NULL). |
[in] | max | The maximum number of elements allowed. |
[in] | free_node | Function to use to free node data if the fifo is freed. |
- Returns
- A new fifo queue.
- NULL on error.
Definition at line 85 of file fifo.c.
◆ fr_fifo_num_elements()
unsigned int fr_fifo_num_elements |
( |
fr_fifo_t * |
fi | ) |
|
Return the number of elements in the fifo queue.
- Parameters
-
[in] | fi | FIFO to count elements in. |
- Returns
- the number of elements
Definition at line 170 of file fifo.c.
◆ fr_fifo_peek()
Examine the next element that would be popped.
- Parameters
-
- Returns
- The data at the head of the queue
- NULL if the queue is empty.
Definition at line 158 of file fifo.c.
◆ fr_fifo_pop()
Pop data off of the fifo.
- Parameters
-
[in] | fi | FIFO to pop data from. |
- Returns
- The data popped.
- NULL if the queue is empty.
Definition at line 135 of file fifo.c.
◆ fr_fifo_push()
int fr_fifo_push |
( |
fr_fifo_t * |
fi, |
|
|
void * |
data |
|
) |
| |
Push data onto the fifo.
- Parameters
-
[in] | fi | FIFO to push data onto. |
[in] | data | to push. |
- Returns
- 0 on success.
- -1 on error.
Definition at line 111 of file fifo.c.