GithubHelp home page GithubHelp logo

skyformat99 / queue-3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smfsw/queue

0.0 0.0 0.0 1.87 MB

Queue handling library (designed on Arduino)

License: BSD 3-Clause "New" or "Revised" License

C++ 100.00%

queue-3's Introduction

Queue Build Status

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...

Usage

  • Declare a cppQueue instance (uint16_t size_rec, uint16_t nb_recs=20, QueueType type=FIFO, overwrite=false) (called q below):
    • size_rec - size of a record in the queue
    • nb_recs - number of records in the queue
    • type - Queue implementation type: FIFO, LIFO
    • overwrite - Overwrite previous records when queue is full if set to true
  • Push stuff to the queue using q.push(void * rec)
    • returns true if successfully pushed into queue
    • returns false is queue is full
  • Pop stuff from the queue using q.pop(void * rec) or q.pull(void * rec)
    • returns true if successfully popped from queue
    • returns false if queue is empty
  • Peek stuff from the queue using q.peek(void * rec)
    • returns true if successfully peeked from queue
    • returns false if queue is empty
  • Drop stuff from the queue using q.drop(void)
    • returns true if successfully dropped from queue
    • returns false if queue is empty
  • Peek stuff at index from the queue using q.peekIdx(void * rec, uint16_t idx)
    • returns true if successfully peeked from queue
    • returns false if index is out of range
    • warning: no associated drop function, not to use with q.drop
  • Peek latest stored from the queue using q.peekPrevious(void * rec)
    • returns true if successfully peeked from queue
    • returns false if queue is empty
    • warning: no associated drop function, not to use with q.drop
    • note: only useful with FIFO implementation, use q.peek instead with a LIFO
  • Other methods:
    • q.isInitialized(): true if initialized properly, false otherwise
    • q.isEmpty(): true if empty, false otherwise
    • q.isFull(): true if full, false otherwise
    • q.sizeOf(): queue size in bytes (returns 0 in case queue allocation failed)
    • q.getCount() or q.nbRecs(): number of records stored in the queue
    • q.getRemainingCount(): number of records left in the queue
    • q.clean() or q.flush(): remove all items in the queue

Notes

  • Interrupt safe automation is not implemented in the library. You have to manually disable/enable interrupts where required. No implementation will be made as it would be an issue when using peek/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.

Examples included

Documentation

Doxygen doc can be generated using "Doxyfile".

See generated documentation

Release Notes

See release notes

See also

cQueue - C implementation of this library

queue-3's People

Contributors

per1234 avatar reydelleon avatar smfsw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.