CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
list_api.h File Reference

The declarations in this header file correspond to the definitions in list.c. Many of the functions here are static in-line for performance reasons and they don't contain much logic. More...

#include "utilities_api.h"
#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
#include "cdi_os_api.h"

Go to the source code of this file.

Data Structures

struct  CdiListEntry
 This structure represents a single list entry. More...
 
struct  CdiList
 This structure represents a list. More...
 
struct  CdiListIterator
 This structure represents a list iterator. More...
 

Typedefs

typedef struct CdiListEntry CdiListEntry
 Forward declaration to create pointer to list entry when used.
 

Functions

void CdiListInit (CdiList *list_ptr)
 
static CdiListEntryCdiListGetHead (CdiList *list_ptr)
 
static bool CdiListIsEmpty (const CdiList *list_ptr)
 
static void CdiListAddAfter (CdiList *list_ptr, CdiListEntry *new_entry_ptr, CdiListEntry *prev_entry_ptr)
 
static void CdiListAddBefore (CdiList *list_ptr, CdiListEntry *new_entry_ptr, CdiListEntry *next_entry_ptr)
 
static void CdiListAddHead (CdiList *list_ptr, CdiListEntry *new_entry_ptr)
 
static void CdiListAddTail (CdiList *list_ptr, CdiListEntry *new_entry_ptr)
 
static CdiListEntryCdiListPeek (const CdiList *list_ptr)
 
static CdiListEntryCdiListPeekTail (const CdiList *list_ptr)
 
static void CdiListRemove (CdiList *list_ptr, CdiListEntry *entry_ptr)
 
static CdiListEntryCdiListPop (CdiList *list_ptr)
 
static int CdiListCount (const CdiList *list_ptr)
 
static void CdiListIteratorInit (CdiList *list_ptr, CdiListIterator *ret_iterator_ptr)
 
static CdiListEntryCdiListIteratorGetNext (CdiListIterator *iterator_ptr)
 

Detailed Description

The declarations in this header file correspond to the definitions in list.c. Many of the functions here are static in-line for performance reasons and they don't contain much logic.

Function Documentation

◆ CdiListAddAfter()

static void CdiListAddAfter ( CdiList * list_ptr,
CdiListEntry * new_entry_ptr,
CdiListEntry * prev_entry_ptr )
inlinestatic

Add a new entry after the item specified in prev_ptr. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
new_entry_ptrPointer to new entry to add to the list.
prev_entry_ptrPointer to entry to add the new item after.

◆ CdiListAddBefore()

static void CdiListAddBefore ( CdiList * list_ptr,
CdiListEntry * new_entry_ptr,
CdiListEntry * next_entry_ptr )
inlinestatic

Add a new entry before the item specified in next_ptr. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
new_entry_ptrPointer to new entry to add to the list.
next_entry_ptrPointer to entry to add the new item before.

◆ CdiListAddHead()

static void CdiListAddHead ( CdiList * list_ptr,
CdiListEntry * new_entry_ptr )
inlinestatic

Add a new entry to the head of the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
new_entry_ptrPointer to new entry to add to the list.

◆ CdiListAddTail()

static void CdiListAddTail ( CdiList * list_ptr,
CdiListEntry * new_entry_ptr )
inlinestatic

Add a new entry to the tail of the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
new_entry_ptrPointer to new entry to add to the list.

◆ CdiListCount()

static int CdiListCount ( const CdiList * list_ptr)
inlinestatic

Get the number of items in the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
Number of items in the list.

◆ CdiListGetHead()

static CdiListEntry * CdiListGetHead ( CdiList * list_ptr)
inlinestatic

Get the head pointer of the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
Pointer to the head list entry.

◆ CdiListInit()

void CdiListInit ( CdiList * list_ptr)

Initialize a list. Doesn't need to be inline, since it is only used once for each instance of the list.

NOTE: All the APIs in this file are not thread-safe. However, read list entry APIs that use next_entry_ptr such as CdiListIteratorGetNext() can be used without thread-safe resource locks.

Parameters
list_ptrPointer to instance of the list.

◆ CdiListIsEmpty()

static bool CdiListIsEmpty ( const CdiList * list_ptr)
inlinestatic

Check if the list is empty. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
True if the list is empty, otherwise false.

◆ CdiListIteratorGetNext()

static CdiListEntry * CdiListIteratorGetNext ( CdiListIterator * iterator_ptr)
inlinestatic

Get the next entry in an iterator list. Concerning thread-safety,

See also
CdiListInit().
Parameters
iterator_ptrPointer to list entry to get the next element.
Returns
next list entry

◆ CdiListIteratorInit()

static void CdiListIteratorInit ( CdiList * list_ptr,
CdiListIterator * ret_iterator_ptr )
inlinestatic

Initialize an iterator list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to list being initialized.
ret_iterator_ptrReturn pointer of list that was initialized.

◆ CdiListPeek()

static CdiListEntry * CdiListPeek ( const CdiList * list_ptr)
inlinestatic

Return the next head entry of the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
Pointer to the head list next entry or NULL if the list is empty.

◆ CdiListPeekTail()

static CdiListEntry * CdiListPeekTail ( const CdiList * list_ptr)
inlinestatic

Return the tail entry of the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
Pointer to the tail list entry or NULL if the list is empty.

◆ CdiListPop()

static CdiListEntry * CdiListPop ( CdiList * list_ptr)
inlinestatic

Pop an item off the head of the list, removing it from the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
Returns
Pointer to the popped head list entry or NULL if the list is empty.

◆ CdiListRemove()

static void CdiListRemove ( CdiList * list_ptr,
CdiListEntry * entry_ptr )
inlinestatic

Remove an item from the list. Concerning thread-safety,

See also
CdiListInit().
Parameters
list_ptrPointer to instance of the list.
entry_ptrPointer to list item to remove.