jamesmunns / bbqueue

A SPSC, lockless, no_std, thread safe, queue, based on BipBuffers
Apache License 2.0
417 stars 51 forks source link

Better examples/docs #55

Open jamesmunns opened 4 years ago

jamesmunns commented 4 years ago

We should have more complete examples for common use cases, including (at least):

CC #54 / @justacec

jamesmunns commented 4 years ago

In particular, we should show:

  1. How to declare a BBBuffer at static scope
  2. How to store the Consumer/Producer in RTFM's Resources, or something like cmim's Move container
  3. How to store a GrantR/GrantW in an Option<GrantX<'static, U32>> with RTFM's Resources or something like cmim's Move container
maraisr commented 4 years ago

As a side question; would also be nice to see some examples/docs on how to use this for not just basic bytes, but storing stuff like structs

ianrrees commented 3 years ago

As a newish Rust programmer, the current example's line static BB: BBBuffer<U6> = BBBuffer( ConstBBBuffer::new() ); was a bit confusing due to the implicit use of generic-array.

ost-ing commented 3 years ago

@ianrrees I also found the same thing

jamesmunns commented 3 years ago

As a note @maraisr, I don't plan to have BBQueue support non-byte (e.g. arrays of u8s) data. It does not currently manage things like alignment, so it wouldn't work as a general purpose struct storage item. You could use it with something like serde or postcard if you need to send things across the wire.

In the future, I will be removing the Generic Array usage, you can take a peek at the next generation docs if you want to see what that will look like!

This "next gen" branch will be merged when min_const_generics lands in the next release or two.