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

Const generics port #198

Merged
merged 44 commits into from
Apr 22, 2021
Merged

Const generics port #198

merged 44 commits into from
Apr 22, 2021

Conversation

korken89
Copy link
Contributor

@korken89 korken89 commented Mar 26, 2021

Closes #158
Closes #168
Closes #207
Closes #115

japaric and others added 17 commits March 25, 2021 16:30
I assume there's no reason that only multi-core Producers are marked
Send, while Consumers are not (they're pretty symmetrical).
This change allows the create custom structs with size arguments outside
the heapless crate itself.
on cortex m0  `%` is extremely costly
vec passes tests

vec passes tests with docs as well (besides one with FromIter)

vec passes tests with docs as well (besides one with FromIter)

exposing full API

passing all current tests

starting with string

string test passes mostly

string test passes

ufmt passes

TODO removed

binary_heap wip

binary_heap passes tests

sealed passes

spsc wip

spsc wip2

split wip3

spcs and split passes --lib tests

spcs and split passes --lib tests

spcs and split passes --lib tests

spcs and split passes all tests (doc + lib)

indexmap wip

indexmap passes --lib test

indexmap passes all tests (lib + doc)

indexset passes all tests (lib + doc)

indexset passes all tests (lib + doc)

linear map wip

linear map all test (lib + doc) passes, drop not tested, into_iter(mut self) not implemented

history buffer all test pass (doc + lib), Copy instead of clone atm

serde does not work

pool works, serde still not

serde wip

serde wip

serde wip

serde wip
@korken89 korken89 marked this pull request as draft March 26, 2021 11:50
@kpp
Copy link
Contributor

kpp commented Mar 28, 2021

Hey, there are several fixes for this PR: #199. All tests with const generics passed successfully.

@korken89 korken89 marked this pull request as ready for review April 1, 2021 17:17
Fix cfail tests in const generics
src/spsc/mod.rs Show resolved Hide resolved
src/spsc/mod.rs Outdated Show resolved Hide resolved
src/spsc/split.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@AfoHT AfoHT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner with consts support 👍

src/histbuf.rs Show resolved Hide resolved
src/sealed.rs Outdated Show resolved Hide resolved
@Sympatron
Copy link

Why are spsc::Queue::u8() and spsc::Queue::u16() unsafe now?

@korken89
Copy link
Contributor Author

korken89 commented Apr 8, 2021

@Sympatron The docs state (for Queue::u16()): "Creates an empty queue with a fixed capacity of N. Safety: Assumes N <= u16::MAX.

More or less, we cannot check in const context if N is within the limit of the index.

@burrbull
Copy link
Member

burrbull commented Apr 8, 2021

We can generate safe constructors for limited range of N with macro.

@korken89
Copy link
Contributor Author

korken89 commented Apr 8, 2021

@burrbull How? Const asserts are not allowed to be used with const generics for now.

@burrbull
Copy link
Member

burrbull commented Apr 8, 2021

See #205

src/indexmap.rs Outdated Show resolved Hide resolved
src/histbuf.rs Outdated Show resolved Hide resolved
@burrbull
Copy link
Member

Is this mean you've decided to use atomic usize everywhere?

@korken89
Copy link
Contributor Author

@burrbull Yes, the implementation that existed was not easily amendable to the fix of #207, and the known good implementation performs very well.
The key here is simplicity, easy to check for correctness - where the old implementation was unfortunately not.

So for now I'll remove the support for smaller queue indexes, and we can reintroduce them in the future if necessary.

This commit implements a new, simplified, SPSC that does not have the
reported issues (e.g. not properly wrapping the indexes for non
powers-of-2), and the support for multiple different index sizes has
been removed for simplicity.
@korken89 korken89 merged commit bd32ab8 into master Apr 22, 2021
@korken89 korken89 deleted the const_generics branch April 22, 2021 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet