|
Internal Interface Wrap
API reference
|
Lock-free single-producer / single-consumer ring for ISR-to-task hand-off. More...
#include <atomic>#include <cstddef>#include <cstdint>#include <memory>#include <new>Go to the source code of this file.
Classes | |
| class | HfSpscRing< T > |
Lock-free single-producer / single-consumer ring for ISR-to-task hand-off.
One producer (typically an interrupt handler) calls TryPush(); one consumer (a task, or several tasks serialised by a mutex) calls TryPop(). Neither side blocks, takes a lock or allocates. The head and tail are free-running 32-bit counters, published with release/acquire ordering, so the ring is safe across cores.
The capacity is rounded up to a power of two so the counters can wrap at 2^32 without breaking the index mapping. A push into a full ring drops the new element and counts an overrun (the oldest data is kept, as a CAN controller FIFO does).
Storage is allocated once by Init() (not from an ISR).