flume icon indicating copy to clipboard operation
flume copied to clipboard

Generic over backing storage / statically allocated bounded channels

Open kyrias opened this issue 2 years ago • 1 comments

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.

kyrias avatar Aug 17 '23 13:08 kyrias

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 avatar Aug 18 '23 16:08 zesterer