Class RingBuffer
Defined in File ringbuffer.hpp
Class Documentation
-
class RingBuffer
A simple circular buffer implementation used for queued processing of incoming lidar / imu data.
Public Functions
-
inline RingBuffer(std::size_t element_size, std::size_t num_elements)
Create a new RingBuffer instance
- Parameters:
element_size – The size (in bytes) of each element
num_elements – Number of maximum elements in the buffer.
-
inline bool empty()
Check whether there is any data to be read from the buffer at head()
- Returns:
true if there are no elements in the buffer
-
inline bool full()
Check if the ringbuffer is full If the buffer is full, adding new data to it will overwrite or corrupt data at the head() position. This function is only safe to call in the producing thread, i.e. no calls to push() may occur simultaneously.
- Returns:
true if the buffer is full
-
inline uint8_t *head()
- Returns:
A pointer to the current element to read from
-
inline uint8_t *tail()
- Returns:
A pointer to the current element to write to
-
inline void pop()
Remove the current head element from the queue.
-
inline RingBuffer(std::size_t element_size, std::size_t num_elements)