RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Classes
OsQueue.h File Reference

Lightweight C++ wrapper for the RTOS queue primitive. More...

#include <cstdint>
#include <cstddef>
#include <climits>
#include <cstring>
#include <type_traits>
#include "OsAbstraction.h"
#include "OsUtility.h"

Go to the source code of this file.

Classes

class  OsQueue< MessageType, kCapacity >
 Fixed-capacity, eager-init MPMC queue of trivially-copyable items. More...
 

Detailed Description

Lightweight C++ wrapper for the RTOS queue primitive.

Thread-safety: internally thread-safe; the underlying FreeRTOS queue is already MT-safe so no extra mutex is layered on top.

Allocation: queue storage is held inline as a member array sized by the backend's OS_QUEUE_STORE_BYTES(); on FreeRTOS (with static allocation) and ThreadX the kernel queue lives there and nothing is taken from the heap. CMSIS-RTOS2 allocates the queue in the kernel. The underlying RTOS queue is created eagerly in the constructor.

Items travel through the kernel as whole 32-bit words: Send() and Receive() copy through a word buffer, so a MessageType whose size is not a multiple of 4 is never read or written past its end.

Public surface uses modern C++ types — uint32_t timeout_ms, bool. No OS_Ulong / OS_WAIT_FOREVER leakage. Pass UINT32_MAX to wait forever.