Utility Ring Buffer
imported from pichenettes/stmlib
#include <ringbuffer.h>
Public Member Functions | |
| RingBuffer () | |
| void | Init () |
| size_t | capacity () const |
| size_t | writable () const |
| size_t | readable () const |
| bool | isEmpty () const |
| void | Write (T v) |
| void | Overwrite (T v) |
| T | Read () |
| T | ImmediateRead () |
| void | Flush () |
| void | Swallow (size_t n) |
| void | ImmediateRead (T *destination, size_t num_elements) |
| void | Overwrite (const T *source, size_t num_elements) |
| void | Advance (size_t num_elements) |
| T * | GetMutableBuffer () |
|
inline |
|
inline |
Advances the write pointer, for when a peripheral is writing to the buffer.
|
inline |
|
inline |
Flushes unread elements from the ring buffer
|
inline |
Returns a pointer to the actual Ring Buffer Useful for when a peripheral needs direct access to the buffer.
|
inline |
Reads next element from ring buffer immediately
|
inline |
Reads a number of elements into a buffer immediately
| destination | buffer to write to |
| num_elements | number of elements in buffer |
|
inline |
Initializes the Ring Buffer
|
inline |
|
inline |
Overwrites a number of elements using the source buffer as input.
| source | Input buffer |
| num_elements | Number of elements in source |
|
inline |
Writes the new element to the ring buffer, overwriting unread data if necessary.
| v | Value to overwrite |
|
inline |
Reads the first available element from the ring buffer
|
inline |
|
inline |
Read enough samples to make it possible to read 1 sample.
| n | Size of T ? |
|
inline |
|
inline |
Writes the value to the next available position in the ring buffer
| v | Value to write |