Skip to content

split a StaticThingBuf into a MPSC #17

@hawkw

Description

@hawkw

it would be nice to have a totally-non-allocating MPSC variant for embedded etc where instead of an Arc<ThingBuf<T>> the queue is stored in an &'static ThingBuf<T>. we can now do this even with waiting tasks now that #16 added an intrusive wait queue that doesn't allocate.

i think that the API for this will have to be something like:

static SOME_QUEUE: thingbuf::StaticMpsc<Event, 1024> = thingbuf::StaticMpsc::new();

fn main() {
    let (tx, rx) = SOME_QUEUE.try_split()
         .expect("queue split into sender/receiver pair more than once");
    // ...
}

because that's the only nice way to get all the important stuff in a static initializer and hand out &'static refs to it to a sender/receiver pair. i don't think we can just add a try_split to the normal StaticThingbuf type since the shared state also needs rx/tx wait cells...

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions