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

V0.4.0 #37

Merged
merged 35 commits into from
Dec 4, 2019
Merged

V0.4.0 #37

merged 35 commits into from
Dec 4, 2019

Conversation

jamesmunns
Copy link
Owner

@jamesmunns jamesmunns commented Nov 22, 2019

This is a pretty radical refactor.

On the plus side, this adds:

  • const constructors of backing data, removing the need for macro initializers and static mut buffers
  • Now is pseudo-generically sized with generic-array
  • grants now automatically commit on drop
  • commit/release methods are now on the grants, rather than on the producer/consumer
  • For now, only offers interfaces if you split into a producer and consumer
  • I haven't added grant max yet, I plan to implement these interfaces first

I still need to:

  • Finish fixing tests
  • Update docs
  • probably one more sanity check of all the unsafe code
  • re-implement grant methods
  • Figure out a reasonable way to use in std, e.g. with a box
  • Maybe implement an unsplit BBQueue instance

CC @jonas-schievink @korken89 @utaal @Disasm

@jamesmunns
Copy link
Owner Author

This has been published as 0.4.0-alpha1. If you want a good quick overview, check out this set of tests to see usage

@Disasm
Copy link
Contributor

Disasm commented Nov 25, 2019

Will there be a way to use this library on top of static buffers?

@jamesmunns
Copy link
Owner Author

@Disasm you'll be able to to create a buffer at static scope, see these docs for details. You won't need to/be able to create one with a separate static &mut [u8] buffer anymore.

@Disasm
Copy link
Contributor

Disasm commented Nov 25, 2019

Oh, missed that part, thanks! Are there any reasons to not use const fn new() for BBBuffer?

@jamesmunns
Copy link
Owner Author

Unfortunately, you cannot provide trait bounds on const functions in stable rust today, which is problematic for my usage of generic-array as a backing buffer, which requires that the size generic parameter have the ArrayLength<u8> trait bound. I use the same hack/workaround as the heapless crate to get around this, but it does require the slightly awkward BBBuffer( ConstBBBuffer::new() ) syntax.

@korken89
Copy link

Nice update!

Could you expand on why the runtime check for already split is needed? It is not quite clear to me.
It seems as if the buffer is implementing a singleton check (on the Producer and Consumer) within itself, rather than having users make a singleton object if they want one.
Is this perhaps the intended use-case?

@jamesmunns
Copy link
Owner Author

@korken89 I'm not of any other way to do this without runtime checking that:

  1. Keeps the backing buffer alive, e.g. does not consume or move the buffer
  2. Allows the backing structure to be immutable, preventing the need of unsafe to interact with it if it is stored at static scope

@jamesmunns jamesmunns marked this pull request as ready for review December 4, 2019 13:06
@jamesmunns
Copy link
Owner Author

I'm going to merge this, and start working on the v0.4.0 branch. I'll open up tracking issues for things that didn't make it in the 0.4.0 release, but could make it in 0.4.x releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants