QTip
C library for queues
Loading...
Searching...
No Matches
qtip.c File Reference

API for queues. More...

#include "qtip.h"
#include <string.h>
Include dependency graph for qtip.c:

Go to the source code of this file.

Macros

#define CHECK_NULL_PRT(ptr)   (((ptr) != NULL) ? QTIP_STATUS_OK : QTIP_STATUS_NULL_PTR)
 Check whether the input is a null pointer.
 
#define IS_LOCKED(context)   ((!is_locked((context))) ? QTIP_STATUS_OK : QTIP_STATUS_LOCKED)
 Check whether the queue is locked.
 
#define CHECK_STATUS(status, exp)   (((status) == QTIP_STATUS_OK) ? (exp) : (status))
 Combine the current status with a new expression.
 

Functions

qtipStatus_t qtip_init (qtipContext_t *pContext, void *pBuffer, 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_rear (qtipContext_t *pContext, void *pItem)
 Gets the item at the rear of the queue.
 
qtipStatus_t qtip_get_front (qtipContext_t *pContext, void *pItem)
 Gets the item at the front of 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_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_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.
 

Detailed Description

API for queues.

Author
Jose Amador

Definition in file qtip.c.

Macro Definition Documentation

◆ CHECK_NULL_PRT

#define CHECK_NULL_PRT (   ptr)    (((ptr) != NULL) ? QTIP_STATUS_OK : QTIP_STATUS_NULL_PTR)

Check whether the input is a null pointer.

Definition at line 19 of file qtip.c.

◆ IS_LOCKED

#define IS_LOCKED (   context)    ((!is_locked((context))) ? QTIP_STATUS_OK : QTIP_STATUS_LOCKED)

Check whether the queue is locked.

Definition at line 24 of file qtip.c.

◆ CHECK_STATUS

#define CHECK_STATUS (   status,
  exp 
)    (((status) == QTIP_STATUS_OK) ? (exp) : (status))

Combine the current status with a new expression.

Definition at line 29 of file qtip.c.