cQueue 2.0
Queue handling library (written in plain c)
|
Queue handling library (written in plain c)
This library is designed for a c implementation on embedded devices, yet may be compiled without change with gcc for other purposes/targets. Designed as a library to be compatible with Arduino LibManager specifications (yet rather use Queue instead - https://github.com/SMFSW/Queue).
q_init(Queue_t * pQ, size_t size_rec, uint16_t nb_recs, QueueType type, bool overwrite)
:pQ
- pointer to the queue structsize_rec
- size of a record in the queuenb_recs
- number of records in the queuetype
- queue implementation type: FIFO
, LIFO
overwrite
- overwrite previous records when queue is full if set to true
q_init_static(Queue_t * pQ, size_t size_rec, uint16_t nb_recs, QueueType type, bool overwrite, void * pQDat, size_t lenQDat)
:pQ
- pointer to the queue structsize_rec
- size of a record in the queuenb_recs
- number of records in the queuetype
- queue implementation type: FIFO
, LIFO
overwrite
- overwrite previous records when queue is full if set to true
pQDat
- pointer to static data queuelenQDat
- length of static data queue (in bytes)q_push(Queue_t * pQ, void * rec)
true
if successfully pushed into queuefalse
is queue is fullq_pop(Queue_t * pQ, void * rec)
or q_pull(Queue_t * pQ, void * rec)
true
if successfully popped from queuefalse
if queue is emptyq_peek(Queue_t * pQ, void * rec)
true
if successfully peeked from queuefalse
if queue is emptyq_drop(Queue_t * pQ)
true
if successfully dropped from queuefalse
if queue is emptyq_peekIdx(Queue_t * pQ, void * rec, uint16_t idx)
true
if successfully peeked from queuefalse
if index is out of rangeq_drop
q_peekPrevious(Queue_t * pQ, void * rec)
true
if successfully peeked from queuefalse
if queue is emptyq_drop
q_peek
instead with a LIFOq_isInitialized(Queue_t * pQ)
: true
if initialized properly, false
otherwiseq_isEmpty(Queue_t * pQ)
: true
if empty, false
otherwiseq_isFull(Queue_t * pQ)
: true
if full, false
otherwiseq_sizeof(Queue_t * pQ)
: queue size in bytes (returns 0 in case queue allocation failed)q_getCount(Queue_t * pQ)
or q_nbRecs(Queue_t * pQ)
: number of records stored in the queueq_getRemainingCount(Queue_t * pQ)
: number of records left in the queueq_clean(Queue_t * pQ)
or q_flush(Queue_t * pQ)
: remove all items in the queuepeek
/drop
methods with LIFO implementation: if an item is put to the queue through interrupt between peek
and drop
calls, the drop
call would drop the wrong (newer) item. In this particular case, dropping decision must be made before re-enabling interrupts.Doxygen doc can be generated using "Doxyfile".
See release notes
Queue - Cpp implementation of this library