Ringbuffer with fixed size but variable capacity? #143
Unanswered
romainreignier
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For an embedded project using
no_std
and noalloc
, I would like a ring buffer but the number of elements allowed in the buffer can be changed at runtime based on a configuration value.For now, it seems to me that ConstGenericRingBuffer need to know its capacity at compile time while an AllocRingBuffer is preferred to my use-case but I need to enable a GlobalAllocator in my application.
So something like a ConstGenericRingBuffer with a compile-time max size and a runtime capacity would cover my need, the max size would be allocated on the stack and my application have to make sure to not require a capacity greater than the size.
But is it something common enough to try to implement it?
If I really need to add an allocator for AllocRingBuffer, maybe we could implement a constructor taking an allocator as argument like Vec::new_in using the Rust
allocator_api
feature, as explained in the esp-alloc crate doc to avoid the GlobalAllocator and allow better control over allocations.Beta Was this translation helpful? Give feedback.
All reactions