class
GrowableRingBufferA ring buffer implementation that supports resizing. Useful for suballocating and reusing buffer memory.
To increase capacity, user allocated tp::
Implemented as a list of regular fixed size ring buffers. The ring buffers are considered for allocation in sequence, starting with the last used one.
Public functions
- auto getAllocationCount() const -> uint64_t
- Returns the number of active allocations.
- auto getAllocationSize() const -> uint64_t
- Returns the total size of all allocations in bytes.
- auto getRegionCount() const -> uint64_t
- Returns the number of regions used so far.
- auto getTotalSize() const -> uint64_t
- Returns the total size of all regions in bytes.
-
void grow(tp::
Buffer* newRegionBuffer) - Adds a new buffer region to be used for suballocating views from.
-
auto peek() -> tp::
BufferView - Returns the least recently allocated tp::
BufferView from this ring buffer. - void pop()
- Frees the least recently allocated tp::
BufferView from this ring buffer, allowing its memory region to be reused. -
auto push(uint64_t allocationSize) -> tp::
BufferView - Tries to allocate a tp::
BufferView with the given size. -
auto pushNoSuballocate(uint64_t allocationSize) -> tp::
BufferView - Tries to allocate a tp::
BufferView with the given size. Every buffer will only serve a single allocation. This function is meant for debugging purposes and isn't ideal for memory consumption. -
auto shrink() -> tp::
Buffer* - Releases a previously added buffer if one is available and unused, otherwise returns nullptr.
Function documentation
void tp:: utils:: GrowableRingBuffer:: grow(tp:: Buffer* newRegionBuffer)
Adds a new buffer region to be used for suballocating views from.
Parameters | |
---|---|
newRegionBuffer | Pointer to a buffer to use for suballocating views from. |
tp:: BufferView tp:: utils:: GrowableRingBuffer:: push(uint64_t allocationSize)
Tries to allocate a tp::
Parameters | |
---|---|
allocationSize | The size of the allocation to be made. |
If the allocation fails due to a lack of space, the returned view will be null. Use tp::
tp:: BufferView tp:: utils:: GrowableRingBuffer:: pushNoSuballocate(uint64_t allocationSize)
Tries to allocate a tp::
Parameters | |
---|---|
allocationSize | The size of the allocation to be made. |
If the allocation fails due to a lack of space, the returned view will be null. Use tp::