All Projects → EinarArnason → ArduinoQueue

EinarArnason / ArduinoQueue

Licence: MIT License
A lightweight linked list type queue implementation, meant for microcontrollers.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to ArduinoQueue

AlgoDaily
just for fun
Stars: ✭ 118 (+306.9%)
Mutual labels:  queue
coyotes
非常简单的异步命令执行队列
Stars: ✭ 24 (-17.24%)
Mutual labels:  queue
queueable
Convert streams to async ⌛ iterables ➰
Stars: ✭ 43 (+48.28%)
Mutual labels:  queue
k2hash
K2HASH - NoSQL Key Value Store(KVS) library
Stars: ✭ 33 (+13.79%)
Mutual labels:  queue
lfqueue
Minimize lock-free queue ever!
Stars: ✭ 107 (+268.97%)
Mutual labels:  queue
libmcu
A toolkit for firmware development
Stars: ✭ 33 (+13.79%)
Mutual labels:  queue
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (+365.52%)
Mutual labels:  queue
golib
Open version of common golang libraries useful to many projects.
Stars: ✭ 47 (+62.07%)
Mutual labels:  queue
px-fwlib
open source bare-metal C firmware and documentation for microcontrollers
Stars: ✭ 247 (+751.72%)
Mutual labels:  microcontrollers
Agile-Server
A simple, fast, complete Node.js server solution, based on KOA. 简单快速的 、性能强劲的、功能齐全的 node 服务器解决方案合集,基于 KOA。
Stars: ✭ 24 (-17.24%)
Mutual labels:  queue
ustd
Micro-standard-library providing minimal and portable array, queue and map for attiny avr, arduinos, esp8266/32 and linux, mac
Stars: ✭ 14 (-51.72%)
Mutual labels:  queue
coolbeans
Coolbeans is a distributed work queue that implements the beanstalkd protocol.
Stars: ✭ 56 (+93.1%)
Mutual labels:  queue
openmessaging.github.io
OpenMessaging homepage
Stars: ✭ 12 (-58.62%)
Mutual labels:  queue
messenger-extra
Additional transports and serializer support for symfony messenger
Stars: ✭ 20 (-31.03%)
Mutual labels:  queue
php-rsmq
PHP implementation of Redis Simple Message Queue
Stars: ✭ 22 (-24.14%)
Mutual labels:  queue
flask-restful-api-boilerplate
This is boilerplate template for a Python Flask application with things you need to get started.
Stars: ✭ 14 (-51.72%)
Mutual labels:  queue
laravisor
Generate laravel supervisor configuration in easiest way
Stars: ✭ 20 (-31.03%)
Mutual labels:  queue
turnio
🤖 Bot to manage a queue of slack users in a channel
Stars: ✭ 11 (-62.07%)
Mutual labels:  queue
jrsmq
A lightweight message queue for Java that requires no dedicated queue server. Just a Redis server.
Stars: ✭ 28 (-3.45%)
Mutual labels:  queue
O7
Oberon → ARMv{6,7E}-M compiler
Stars: ✭ 27 (-6.9%)
Mutual labels:  microcontrollers

ArduinoQueue

Build Status

A lightweight linked list type queue implementation, meant for microcontrollers. Written as a C++ template class.

Constructors

Creates a queue up to <maximum_number_of_items> items:

ArduinoQueue<T> intQueue(maximum_number_of_items);

Creates a queue up to <maximum_size_in_bytes> bytes:

ArduinoQueue<T> intQueue(0, maximum_size_in_bytes);

Creates a queue up to <maximum_number_of_items> items or <maximum_size_in_bytes> bytes, whatever comes first:

ArduinoQueue<T> intQueue(maximum_number_of_items, maximum_size_in_bytes);

How to use

Include the header file on your code:

#include <ArduinoQueue.h>

Then create the queue according to your needs, examples:

  • To create a queue of int, capable of holding 20 items:
ArduinoQueue<int> intQueue(20);
  • To create a queue of int, capable of holding 20 items or a maximum size of 10 bytes (whatever comes first):
ArduinoQueue<int> intQueue(20, 10);
  • To create a queue of your defined structure, capable of holding 50 items:
struct car {
    char brand[10];
    char model[10];
    int nr_doors;
};
ArduinoQueue<car> myCarsQueue(50);

Finally use the following functions:

intQueue.enqueue(1);    // Adds number 1 to the queue
intQueue.enqueue(123);    // Adds number 123 to the queue
int number = intQueue.dequeue();    // Will return number 1 and remove it from the queue
int number = intQueue.getHead();    // Will return number 123 but leave it still in the queue
int number = intQueue.dequeue();    // Will return number 123 and remove it from the queue

You can use also the following functions to get more queue properties:

bool state = intQueue.isEmpty();    // Returns true if the queue is empty, false otherwise
bool state = intQueue.isFull();    // Returns true if the queue is full, false otherwise
unsigned int n = intQueue.itemCount();    // Returns the number of items currently on the queue
unsigned int n = intQueue.itemSize();    // Returns the size of the item being stored (bytes)
unsigned int n = intQueue.maxQueueSize();    // Returns the maximum possible size of the queue (items)*
unsigned int n = intQueue.maxMemorySize();    // Returns the maximum possible size of the queue (bytes)*

Thread safety

This library is not thread safe. Mutexes are often hardware specific on the way they are optimized to operate. So for the sake of performance and portability, it is left out.

Memory safety

The memory for the queue nodes are dynamically allocated. Note that while the Queue class cleans up the nodes in memory after destructor or dequeue is called, it keeps a copy of the item being queued. So for example if you are queuing pointers, you will need to keep track of the memory behind them.

Performance

CPU: Intel i7-6500U
RAM: DDR4L

Benchmark result (1000 samples):
Enqueued 1000000 ints in average 0.018749799 seconds
Dequeued 1000000 ints in average 0.016496857 seconds
Allocated 15.2588 MB (16 bytes per item)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].