pothosware / PothosCore

The Pothos data-flow framework
https://github.com/pothosware/PothosCore/wiki
Boost Software License 1.0
302 stars 48 forks source link

BufferAccumulator fix for circular buffers. #205

Closed willcode closed 4 years ago

willcode commented 4 years ago

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.

guruofquality commented 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?

willcode commented 4 years ago

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.

guruofquality commented 4 years ago

Well thanks for finding that!