Closed willcode closed 4 years ago
I just want to understand better.
Is there a bug such that the default allocator is not making what is now getAliasOffset() and getLength() the same value?
Or is this a way to better support a custom allocator thats using a circular buffer?
getLength() is the same as getAliasOffset() only if numBuffers == 1. The allocation is bufferSize * numBuffers in CircularBufferManager::init, but getLength() is based only on bufferSize in CircularBufferManager::setCircFrontBuffer. Once the SharedBuffer is created, there's no way of knowing what the actual alias is, since it's only known by the underlying buffer.
Also, I have a custom allocator, and it is not currently possible to create an allocator with an alias using SharedBuffer. The other option was to create a new constructor that included alias, but setAlias() worked out a little better in my case.
Well thanks for finding that!
Handle chunks from circular buffers without memcpy and with backpressure. Add functions to allow setting of alias (for circular buffers not implemented as a part of SharedBuffer) and provide getAliasOffset() to ensure correct offset.