![]() |
QTip
C library for queues
|
Public API. More...
Data Structures | |
struct | qtipContext_t |
Queue context structure. More... | |
Macros | |
#define | QTIP_CPP_SUPPORT_START |
#define | QTIP_CPP_SUPPORT_END |
#define | QTIP_IS_CPP (0U) |
#define | SIZE_TYPE size_t |
Type for holding the number of items in queue. | |
Typedefs | |
typedef size_t | qtipSize_t |
Number of items in queue. | |
Enumerations | |
enum | qtipStatus_t { QTIP_STATUS_OK , QTIP_STATUS_FULL , QTIP_STATUS_EMPTY , QTIP_STATUS_NULL_PTR , QTIP_STATUS_INVALID_SIZE , QTIP_STATUS_LOCKED } |
Queue operation status. More... | |
Functions | |
qtipStatus_t | qtip_init (qtipContext_t *pContext, void *pQueue, qtipSize_t maxItems, size_t itemSize) |
Initialize queue context. | |
qtipStatus_t | qtip_put (qtipContext_t *pContext, void *pItem) |
Put an item in a queue. | |
qtipStatus_t | qtip_pop (qtipContext_t *pContext, void *pItem) |
Extract the next item from the queue. | |
qtipStatus_t | qtip_peek (qtipContext_t *pContext, void *pBuffer, qtipSize_t *pSize) |
Copies every element of the queue into a buffer. | |
qtipStatus_t | qtip_purge (qtipContext_t *pContext) |
Removes all the items from the queue. | |
qtipStatus_t | qtip_get_front (qtipContext_t *pContext, void *pItem) |
Gets the item at the front of the queue. | |
qtipStatus_t | qtip_get_rear (qtipContext_t *pContext, void *pItem) |
Gets the item at the rear of the queue. | |
qtipStatus_t | qtip_is_full (qtipContext_t *pContext) |
Checks whether the queue is full. | |
qtipStatus_t | qtip_is_empty (qtipContext_t *pContext) |
Checks whether the queue is empty. | |
qtipStatus_t | qtip_count_items (qtipContext_t *pContext, qtipSize_t *pResult) |
Gets the number of items in the queue. | |
qtipStatus_t | qtip_get_item_index (qtipContext_t *pContext, qtipSize_t index, void *pItem) |
Gets the item from an intex in the queue. | |
qtipStatus_t | qtip_remove_item_index (qtipContext_t *pContext, qtipSize_t index) |
Removes the item from an intex in the queue. | |
qtipStatus_t | qtip_get_pop_index (qtipContext_t *pContext, qtipSize_t index, void *pItem) |
Pops the item from an intex in the queue. | |
qtipStatus_t | qtip_is_locked (qtipContext_t *pContext) |
Checks whether the queue is locked. | |
qtipStatus_t | qtip_lock (qtipContext_t *pContext) |
Locks the queue. | |
qtipStatus_t | qtip_unlock (qtipContext_t *pContext) |
Unlocks the queue. | |
qtipStatus_t | qtip_total_enqueued_items (qtipContext_t *pContext, size_t *pResult) |
Get number of items inserted in the queue. | |
qtipStatus_t | qtip_total_processed_items (qtipContext_t *pContext, size_t *pResult) |
Get number of processed items in the queue. | |
Public API.
struct qtipContext_t |
Data Fields | ||
---|---|---|
qtipSize_t | maxItems | Number of items allowed in the queue. |
qtipSize_t | qty | Current number of items in the queue. |
void * | start | Pointer to the start of the queue. |
qtipSize_t | front | Absolute index of the front of the queue. |
qtipSize_t | rear | Absolute index of the rear of the queue. |
size_t | itemSize | Size of each item in the queue. |
bool | locked | Lock status. |
size_t | processed | Number of items removed from the queue. |
size_t | total | Number of items introduced to the queue. |
#define SIZE_TYPE size_t |
typedef size_t qtipSize_t |
enum qtipStatus_t |
Queue operation status.
qtipStatus_t qtip_init | ( | qtipContext_t * | pContext, |
void * | pQueue, | ||
qtipSize_t | maxItems, | ||
size_t | itemSize | ||
) |
Initialize queue context.
Initializes the queue context struct with default values.
[in] | pContext | Pointer to queue context |
[in] | pQueue | Pointer to queue in memory. |
[in] | maxItems | Maximum number of items allowed in the queue |
[in] | itemSize | Size of the item to store in the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | itemSize or maxItems is 0 |
Definition at line 163 of file qtip.c.
qtipStatus_t qtip_put | ( | qtipContext_t * | pContext, |
void * | pItem | ||
) |
Put an item in a queue.
Copies the value of pItem to the back of the queue.
[in] | pContext | Pointer to queue context |
[in] | pItem | Pointer to item to store in the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | Queue is full |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 198 of file qtip.c.
qtipStatus_t qtip_pop | ( | qtipContext_t * | pContext, |
void * | pItem | ||
) |
Extract the next item from the queue.
Pulls and removes the the next item in the queue and puts it into pItem.
[in] | pContext | Pointer to queue context |
[out] | pItem | Pointer to item to store in the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | Queue is empty |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 240 of file qtip.c.
qtipStatus_t qtip_peek | ( | qtipContext_t * | pContext, |
void * | pBuffer, | ||
qtipSize_t * | pSize | ||
) |
Copies every element of the queue into a buffer.
Reads every item in the queue and stores a copy in pBuffer
[in] | pContext | Pointer to queue context |
[in] | pBuffer | Pointer to buffer to store the copy of the queue |
[out] | pSize | Pointer to variable to store the number of items in the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext , pItem , or pSIze is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 283 of file qtip.c.
qtipStatus_t qtip_purge | ( | qtipContext_t * | pContext | ) |
Removes all the items from the queue.
Deletes the items from the queue and sets the queue in a known state.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 316 of file qtip.c.
qtipStatus_t qtip_get_front | ( | qtipContext_t * | pContext, |
void * | pItem | ||
) |
Gets the item at the front of the queue.
The item at the front of the queue is fetched, but not removed.
[in] | pContext | Pointer to queue context |
[out] | pItem | Pointer to the item at the front of the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | Queue is empty |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 383 of file qtip.c.
qtipStatus_t qtip_get_rear | ( | qtipContext_t * | pContext, |
void * | pItem | ||
) |
Gets the item at the rear of the queue.
The item at the rear of the queue is fetched, but not removed.
[in] | pContext | Pointer to queue context |
[out] | pItem | Pointer to the item at the rear of the queue |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | Queue is empty |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 347 of file qtip.c.
qtipStatus_t qtip_is_full | ( | qtipContext_t * | pContext | ) |
Checks whether the queue is full.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Queue is not full |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | Queue is full |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 472 of file qtip.c.
qtipStatus_t qtip_is_empty | ( | qtipContext_t * | pContext | ) |
Checks whether the queue is empty.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Queue is not empty |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | Queue is empty |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 488 of file qtip.c.
qtipStatus_t qtip_count_items | ( | qtipContext_t * | pContext, |
qtipSize_t * | pResult | ||
) |
Gets the number of items in the queue.
[in] | pContext | Pointer to queue context |
[out] | pResult | Pointer to the variable to hold the result |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 504 of file qtip.c.
qtipStatus_t qtip_get_item_index | ( | qtipContext_t * | pContext, |
qtipSize_t | index, | ||
void * | pItem | ||
) |
Gets the item from an intex in the queue.
Returns the item in the requested position, where index = 0
results in the item at the front of the queue.
[in] | pContext | Pointer to queue context |
[in] | index | Item index relative to the front of the queue (0 -> front) |
[out] | pItem | Pointer to the variable to hold the result |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | Index unavailable |
Definition at line 520 of file qtip.c.
qtipStatus_t qtip_remove_item_index | ( | qtipContext_t * | pContext, |
qtipSize_t | index | ||
) |
Removes the item from an intex in the queue.
Removes the item in the requested position, where index = 0
is the item at the front of the queue.
[in] | pContext | Pointer to queue context |
[in] | index | Item index relative to the front of the queue (0 -> front) |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | Index unavailable |
Definition at line 543 of file qtip.c.
qtipStatus_t qtip_get_pop_index | ( | qtipContext_t * | pContext, |
qtipSize_t | index, | ||
void * | pItem | ||
) |
Pops the item from an intex in the queue.
Returns and removes the item in the requested position, where index = 0
is the item at the front of the queue.
[in] | pContext | Pointer to queue context |
[in] | index | Item index relative to the front of the queue (0 -> front) |
[out] | pItem | Pointer to the variable to hold the result |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext or pItem is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | Index unavailable |
Definition at line 567 of file qtip.c.
qtipStatus_t qtip_is_locked | ( | qtipContext_t * | pContext | ) |
Checks whether the queue is locked.
Deletes the items from the queue and sets the queue in a known state.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Queue is not locked |
QTIP_STATUS_LOCKED | Queue is locked |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 421 of file qtip.c.
qtipStatus_t qtip_lock | ( | qtipContext_t * | pContext | ) |
Locks the queue.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 437 of file qtip.c.
qtipStatus_t qtip_unlock | ( | qtipContext_t * | pContext | ) |
Unlocks the queue.
[in] | pContext | Pointer to queue context |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 453 of file qtip.c.
qtipStatus_t qtip_total_enqueued_items | ( | qtipContext_t * | pContext, |
size_t * | pResult | ||
) |
Get number of items inserted in the queue.
The result considers the all-time number of inserted items.
[in] | pContext | Pointer to queue context |
[out] | pResult | Pointer to variable to hold the result |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext or pResult is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 597 of file qtip.c.
qtipStatus_t qtip_total_processed_items | ( | qtipContext_t * | pContext, |
size_t * | pResult | ||
) |
Get number of processed items in the queue.
The result considers the all-time number of popped items.
[in] | pContext | Pointer to queue context |
[out] | pResult | Pointer to variable to hold the result |
Returned qtipStatus_t | Reason |
---|---|
QTIP_STATUS_OK | Operation successful |
QTIP_STATUS_LOCKED | NA |
QTIP_STATUS_NULL_PTR | pContext or pResult is NULL |
QTIP_STATUS_FULL | NA |
QTIP_STATUS_EMPTY | NA |
QTIP_STATUS_INVALID_SIZE | NA |
Definition at line 614 of file qtip.c.