Simple Collections
Loading...
Searching...
No Matches
tccollection::GenericCircularBuffer< T > Class Template Reference

#include <SCCircularBuffer.h>

Public Types

enum  BufferType { CIRCULAR_BUFFER , MEMORY_POOL }

Public Member Functions

 GenericCircularBuffer (uint16_t size, BufferType asMemPool=CIRCULAR_BUFFER)
bool available () const
void put (const T &by)
T & get ()
int16_t nextPosition (position_ptr_t positionPtr)

Public Attributes

volatile uint32_t casExchangeSpins = 0

Detailed Description

template<class T>
class tccollection::GenericCircularBuffer< T >

Create a circular buffer that has a fixed size and can be filled and read at the same time one character at a time. It is very thread safe on ESP32 and mbed based boards, it is thread safe on other boards, unless you are using that board with an unexpected RTOS, in which case you would need to determine suitability yourself.

Imagine the buffer like a circle with a given number of segments, both the reader and writer pointers start at 0. As the data structure fills up the writer will move around, and the reader can try and "keep up". Once the reader or writer gets to the end it will go back to 0 (start). This is by design and therefore, IT'S POSSIBLE TO LOSE DATA.


The documentation for this class was generated from the following file: