Queue library

Library overview

Queue is a lightweight embedded library that implements a FIFO (First-In, First-Out) data structure for efficient and predictable data exchange between software modules. It helps decouple producers and consumers by providing a clear buffering mechanism, keeping execution flow simple and deterministic – a key requirement in embedded systems.

The library is fully configurable at compile time, allowing developers to define queue capacity and element size according to the application’s requirements. Its minimal design ensures predictable memory usage and low overhead, making it suitable for both small microcontrollers and larger embedded systems.

With a simple and explicit API, Queue enables safe and structured data transfer between modules, interrupts, and tasks without introducing hidden complexity or dynamic memory allocation. Here is an example of communication between software modules using queue:

queuediagram
Key characteristics
  • FIFO ordering – preserves the exact order of inserted elements
  • Deterministic operations – all functions execute in constant time
  • Static memory usage – no hidden allocations, fully controlled by the user
  • Lightweight and portable – minimal footprint and easy integration
  • Explicit design – clear ownership of data and memory, simple and safe API
Core functionality

The library provides a minimal and well-defined API for queue operations:

  • Initialize a queue instance with a user-provided buffer
  • Add elements to the back of the queue (enqueue)
  • Remove elements from the front of the queue (dequeue)
  • Access the front element without removing it (peek)
  • Check whether the queue is empty or full

All operations are designed to be predictable, efficient, and safe when used according to documented preconditions.

Configuration & resource usage

Queue does not manage memory internally. The application defines:

  • Queue capacity through the provided buffer
  • Element size depending on stored data
  • Total memory usage, known at compile time

This ensures full control over system resources and makes the library suitable for resource-constrained or safety-critical environments.

Intended use cases
  • Communication between interrupt and main context
  • Producer–consumer patterns
  • Buffering of sensor data or messages
  • Integration in bare-metal or RTOS-based firmware
Documentation & examples
  • Detailed API reference is available in Doxygen documentation
  • A complete example application demonstrates typical usage patterns and integration
  • The example  application is available also in GitHub: Queue-Example

Are you interested?

Scroll to Top