|
Queue 2.0
Queue handling library
|
Queue handling library (designed on Arduino)
This library was designed for Arduino, yet may be compiled without change with gcc for other purposes/targets
Queue class has since start been called Queue. Unfortunately, on some platforms or when using FreeRTOS, Queue is already declared. For compatibility purposes, Queue class has been renamed to cppQueue. Sorry for the inconvenience...
cppQueue instance (size_t size_rec, uint16_t nb_recs=20, QueueType type=FIFO, bool overwrite=false, void * pQDat=NULL, size_t lenQDat=0) (called q below):size_rec - size of a record in the queuenb_recs - number of records in the queuetype - queue implementation type: FIFO, LIFOoverwrite - overwrite previous records when queue is full if set to truepQDat - pointer to static data queuelenQDat - length of static data queue (in bytes)q.push(void * rec)true if successfully pushed into queuefalse is queue is fullq.pop(void * rec) or q.pull(void * rec)true if successfully popped from queuefalse if queue is emptyq.peek(void * rec)true if successfully peeked from queuefalse if queue is emptyq.drop(void)true if successfully dropped from queuefalse if queue is emptyq.peekIdx(void * rec, uint16_t idx)true if successfully peeked from queuefalse if index is out of rangeq.dropq.peekPrevious(void * rec)true if successfully peeked from queuefalse if queue is emptyq.dropq.peek instead with a LIFOq.isInitialized(): true if initialized properly, false otherwiseq.isEmpty(): true if empty, false otherwiseq.isFull(): true if full, false otherwiseq.sizeOf(): queue size in bytes (returns 0 in case queue allocation failed)q.getCount() or q.nbRecs(): number of records stored in the queueq.getRemainingCount(): number of records left in the queueq.clean() or q.flush(): 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.cQueue - C implementation of this library