Skip to content

Support externally provided storage for Channel #66

@sandersaares

Description

@sandersaares

This is one of my favorite crates but one tiny thing is nagging at me - that heap allocation for Channel! I would like to manage the allocation of the Channel myself and just call something like unsafe fn channel_with_external_storage<T>(channel_ptr: NonNull<Channel<T>>, drop_channel: fn(NonNull<Channel<T>>)) -> (Sender<T>, Receiver<T>) which would let me manage the memory and control what happens on drop.

The goal is to ultimately enable allocation-free scenarios by reusing Channel and/or embedding it inside other objects.

Does this sound feasible? I suppose this would need to be some pub struct ExternalChannel<T> { real_channel: Channel<T> } to hide any details of the channel object and just let the caller provide storage for it.

WDYT? I can try come up with a pull request at some point if it sounds like a feature that would be a good fit for this crate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions