Template Class CircularBuffer
Defined in File CircularBuffer.hpp
Nested Relationships
Nested Types
Class Documentation
Fixed-size circular buffer, thread-safe (mutex-based), copyable.
All storage is allocated in the constructor. Push and pop never allocate. Copying the buffer creates a new internal storage and copies the content. This class is safe for multiple producers and consumers, but access is serialized by a single mutex.
Public Functions
Construct a buffer with the given capacity.
Copy constructor.
Creates a new buffer with the same capacity and copies all elements and index state. The internal mutex is not shared.
Copy assignment.
Move operations are optional. For now we delete them to avoid surprising semantics.
Maximum number of elements that can be stored.
Current number of valid elements.
True if the buffer is empty.
True if the buffer is full.
Remove all elements, keeping the allocated storage.
Push a new element (copy). Overwrites the oldest if the buffer is full.
Push a new element (move). Overwrites the oldest if the buffer is full.
Pop the oldest element.
- Parameters:
out – Destination for the oldest element.
- Returns:
False if the buffer is empty.
Get a copy of the newest element without removing it.
- Parameters:
out – Destination for the newest element.
- Returns:
False if the buffer is empty.
Get a const reference to the newest element without removing it.
Public Members