Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Buffered FIFO

This is an implementation of a Buffered FIFO data storage. More...

Modules

 Internals
 Not to be used directly.
 

Data Structures

struct  Buffered_FIFO
 This is a struct defining a FIFO It is composed of several Buffered_FIFO_chunk. More...
 

Functions

void Buffered_FIFO_init (struct Buffered_FIFO *fifo, uint64_t chunk_size, size_t elem_size)
 Initializes a Buffered_FIFO. More...
 
void Buffered_FIFO_release (struct Buffered_FIFO *fifo, void(*free_func)(void *))
 releases a FIFO More...
 
void * Buffered_FIFO_push (struct Buffered_FIFO *fifo, void *elem)
 Pushes an element into a FIFO. More...
 
void * Buffered_FIFO_pop (struct Buffered_FIFO *fifo, void *dest)
 Pops an element from a FIFO. More...
 
uint64_t Buffered_FIFO_count (struct Buffered_FIFO *fifo)
 Thread-safely gets the number of elements stored in the FIFO. More...
 

Detailed Description

This is an implementation of a Buffered FIFO data storage.

The FIFO (Buffered_FIFO) is composed of several fixed size chunks (Buffered_FIFO_chunk).

dot_FIFO.png
Buffered FIFO Illustration

Sample use:

struct Buffered_FIFO fifo;
int i;
Buffered_FIFO_init(&fifo, 9, sizeof( uint64_t ));
#define FIFO_PP_SIZE 3
for( i = 0 ; i < FIFO_PP_SIZE ; i++ )
{
Buffered_FIFO_push( &f, (void*)&i);
}
int out = -1;
while( Buffered_FIFO_pop( &f, &out ) )
{
printf("%d\n", out);
}
Buffered_FIFO_release( &fifo, NULL);
dot_inline_dotgraph_2.png

Thus in this configuration and by definition of the FIFO, we pop elems in order (0,1,2).

Function Documentation

uint64_t Buffered_FIFO_count ( struct Buffered_FIFO fifo)

Thread-safely gets the number of elements stored in the FIFO.

Parameters
fifothe FIFO where to count elements
Returns
the number of elements stored in the FIFO

Definition at line 23 of file Buffered_FIFO.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffered_FIFO_init ( struct Buffered_FIFO fifo,
uint64_t  chunk_size,
size_t  elem_size 
)

Initializes a Buffered_FIFO.

Parameters
fifothe FIFO to initialize
chunk_sizethe wanted size for the chunks
elem_sizethe size of stored elements

Definition at line 119 of file Buffered_FIFO.c.

Here is the caller graph for this function:

void* Buffered_FIFO_pop ( struct Buffered_FIFO fifo,
void *  dest 
)

Pops an element from a FIFO.

Parameters
fifothe FIFO from where to pop the element
destwhere to copy the popped element
Returns
the popped element, NULL if the FIFO is empty

Definition at line 182 of file Buffered_FIFO.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void* Buffered_FIFO_push ( struct Buffered_FIFO fifo,
void *  elem 
)

Pushes an element into a FIFO.

Parameters
fifothe FIFO where to push the element
elemthe element to push
Returns
the internally copied element

Definition at line 143 of file Buffered_FIFO.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void Buffered_FIFO_release ( struct Buffered_FIFO fifo,
void(*)(void *)  free_func 
)

releases a FIFO

Parameters
fifothe FIFO to release
free_func
Warning
free_func parameter is unused. Release of FIFO consists of setting everything to 0 in it.

Definition at line 133 of file Buffered_FIFO.c.

Here is the caller graph for this function: