The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Typedefs | Functions
fifo.h File Reference
#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/talloc.h>
+ Include dependency graph for fifo.h:

Go to the source code of this file.

Macros

#define fr_fifo_create(_ctx, _max_entries, _node_free)    _fr_fifo_create(_ctx, NULL, _max_entries, _node_free)
 Creates a fifo. More...
 
#define fr_fifo_talloc_create(_ctx, _talloc_type, _max_entries, _node_free)    _fr_fifo_create(_ctx, #_talloc_type, _max_entries, _node_free)
 Creates a fifo that verifies elements are of a specific talloc type. More...
 

Typedefs

typedef void(* fr_fifo_free_t) (void *)
 
typedef struct fr_fifo_s fr_fifo_t
 

Functions

fr_fifo_t_fr_fifo_create (TALLOC_CTX *ctx, char const *type, int max_entries, fr_fifo_free_t free_node)
 Create a fifo queue. More...
 
unsigned int fr_fifo_num_elements (fr_fifo_t *fi)
 Return the number of elements in the fifo queue. More...
 
void * fr_fifo_peek (fr_fifo_t *fi)
 Examine the next element that would be popped. More...
 
void * fr_fifo_pop (fr_fifo_t *fi)
 Pop data off of the fifo. More...
 
int fr_fifo_push (fr_fifo_t *fi, void *data)
 Push data onto the fifo. More...
 

Macro Definition Documentation

◆ fr_fifo_create

#define fr_fifo_create (   _ctx,
  _max_entries,
  _node_free 
)     _fr_fifo_create(_ctx, NULL, _max_entries, _node_free)

Creates a fifo.

Parameters
[in]_ctxto tie fifo lifetime to. If ctx is freed, fifo will free any nodes, calling the free function if set.
[in]_max_entriesMaximum number of entries.
[in]_node_freeOptional function used to free data if tree nodes are deleted or replaced.
Returns
  • A new fifo on success.
  • NULL on failure.

Definition at line 66 of file fifo.h.

◆ fr_fifo_talloc_create

#define fr_fifo_talloc_create (   _ctx,
  _talloc_type,
  _max_entries,
  _node_free 
)     _fr_fifo_create(_ctx, #_talloc_type, _max_entries, _node_free)

Creates a fifo that verifies elements are of a specific talloc type.

Parameters
[in]_ctxto tie fifo lifetime to. If ctx is freed, fifo will free any nodes, calling the free function if set.
[in]_max_entriesMaximum number of entries.
[in]_talloc_typeof elements.
[in]_node_freeOptional function used to free data if tree nodes are deleted or replaced.
Returns
  • A new fifo on success.
  • NULL on failure.

Definition at line 51 of file fifo.h.

Typedef Documentation

◆ fr_fifo_free_t

typedef void(* fr_fifo_free_t) (void *)

Definition at line 36 of file fifo.h.

◆ fr_fifo_t

typedef struct fr_fifo_s fr_fifo_t

Definition at line 1 of file fifo.h.

Function Documentation

◆ _fr_fifo_create()

fr_fifo_t* _fr_fifo_create ( TALLOC_CTX *  ctx,
char const *  type,
int  max,
fr_fifo_free_t  free_node 
)

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]ctxto allocate fifo array in.
[in]typeTalloc type of elements (may be NULL).
[in]maxThe maximum number of elements allowed.
[in]free_nodeFunction 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.

+ Here is the call graph for this function:

◆ 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]fiFIFO to count elements in.
Returns
the number of elements

Definition at line 170 of file fifo.c.

+ Here is the caller graph for this function:

◆ fr_fifo_peek()

void* fr_fifo_peek ( fr_fifo_t fi)

Examine the next element that would be popped.

Parameters
[in]fiFIFO to peek at.
Returns
  • The data at the head of the queue
  • NULL if the queue is empty.

Definition at line 158 of file fifo.c.

+ Here is the caller graph for this function:

◆ fr_fifo_pop()

void* fr_fifo_pop ( fr_fifo_t fi)

Pop data off of the fifo.

Parameters
[in]fiFIFO to pop data from.
Returns
  • The data popped.
  • NULL if the queue is empty.

Definition at line 135 of file fifo.c.

+ Here is the caller graph for this function:

◆ fr_fifo_push()

int fr_fifo_push ( fr_fifo_t fi,
void *  data 
)

Push data onto the fifo.

Parameters
[in]fiFIFO to push data onto.
[in]datato push.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 111 of file fifo.c.

+ Here is the caller graph for this function: