bbqueue
bbqueue copied to clipboard
Consumer overwriting oldest data
Hi,
It would be nice if there were one more method for Producer
that tries to "read" the oldest data (to make room for the newest) if the Consumer
is not currently consuming them, otherwise return Err
too.
For example, MCU via DMA receives telemetry data from the motor controller over UART (interesting is only the latest), but MCU is doing something else, so the bbqueue fulls and (if I am not mistaken) the latest data would be lost.
Hi @OpoOpo, at the moment, I don't think this is possible. The lock-free algorithm used by bbqueue currently expects there to only be one Consumer and one Producer, which each have tracking variables they are allowed to update.
Allowing the producer to overwrite the consumer's data would (currently) invalidate this, leading to potential race conditions.
If you think you know a way to correct this, I'd be happy to discuss!
Thank you for your response :-) . Currently, I did not have time to fully explore the bbqueue. It was just an idea that would be nice just from an API perspective.