Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumer overwriting oldest data #88

Open
OpoOpo opened this issue Mar 21, 2021 · 3 comments
Open

Consumer overwriting oldest data #88

OpoOpo opened this issue Mar 21, 2021 · 3 comments

Comments

@OpoOpo
Copy link

OpoOpo commented Mar 21, 2021

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.

@jamesmunns
Copy link
Owner

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!

@OpoOpo
Copy link
Author

OpoOpo commented May 1, 2021

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.

@Sympatron
Copy link
Collaborator

I think this would require a major redesign with different tradeoffs. I would vote to close this as out of scope of this crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants