34#ifndef _UTILS_RINGBUFFER_HXX_
35#define _UTILS_RINGBUFFER_HXX_
76 for (
size_t i = 0; i < inserted; ++i)
100 for (
size_t i = 0; i < removed; ++i)
138 if (
space() < result)
156 size_t consumed =
items;
185 size_t added =
items;
Implements a vanilla ring buffer.
RingBuffer(size_t size)
Constructor.
size_t count
total number of items in ring buffer
size_t writeIndex
write index
size_t advance(size_t items)
Add a number of items to the buffer by advancing the writeIndex.
~RingBuffer()
Default destructor.
size_t readIndex
read index
size_t get(T *buf, size_t items)
remove a number of items from the buffer.
size_t consume(size_t items)
Remove a number of items from the buffer by advancing the readIndex.
void destroy()
Destroy an existing ring buffer instance.
size_t _size
size in items of ring buffer
size_t space()
space left in buffer of buffer in number items.
size_t size()
Size of buffer in number of items.
size_t put(const T *buf, size_t items)
Insert a number of items to the buffer.
size_t data_write_pointer(T **buf)
Get a reference to the current location in the buffer for write.
size_t data_read_pointer(T **buf)
Get a reference to the current location in the buffer for read.
static RingBuffer * create(size_t size)
Factory method to create a ring buffer instance.
size_t items()
Number of items in the buffer.
RingBuffer()
Default Constructor.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.