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

Generic over backing storage / statically allocated bounded channels #131

Open
kyrias opened this issue Aug 17, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@kyrias
Copy link
Contributor

kyrias commented Aug 17, 2023

This might be a bit much to ask for, but it would be very useful on embedded systems if it was possible to statically allocate the backing storage for the inner Chan of bounded channels.

We have some pretty large channels and leaving them to be dynamically allocated seems to lead to a lot of memory fragmentation with the inner VecDeques being reallocated when they need to grow, which would be alleviated by having the storage for these bounded channels statically allocated at compile-time.

Alternatively just having a way to pre-allocate the VecDeques to the max capacity would be helpful as well, albeit not optimal.

@zesterer
Copy link
Owner

zesterer commented Aug 18, 2023

I definitely like this idea! I'm not sure I have time to implement it at the current time, but I think the way I'd go about this would be to give Sender and Receiver a default parameter implementing a Container trait and then go from there (with a way to pass a container / reference to a container to the channel function.

@zesterer zesterer added the enhancement New feature or request label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants