-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add an efficient implementation based on critical-section #148
Conversation
The current no-std implementation is somewhat ineffecient, potentially broken and relies on some slow data structures. The main reason why we use this implementation is because we don't have a way to "lock" the linked list, since there's no way to lock things in no-std. However, many embedded platforms have a concept of a "critical section" that can be used to exclusively lock something. This PR adds an option to the "std" implementation that replaces the existing Mutex with a usage of the critical-section crate. This is enabled with the "critical-section" feature. This allows us to have the advantages of the std-based implementation without needing to rely on std for platforms that don't have it. Signed-off-by: John Nunley <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff! I had planned to look into critical-sections for async-broadcast but never got around to it. However, since a-b depends on event-listener, this is required anyway. I just have a confusion and a nitpick to offer. :)
Since `std.rs` and `no_std.rs` no longer correspond to std and no_std, I've renamed them based on the underlying algorithm used. `std.rs` is now `intrusive.rs`, since it uses an intrusive linked list. `no_std.rs` is now `slab.rs`, since it relies on a structure similar to the one used in the `slab` crate. Signed-off-by: John Nunley <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, there is at least one small problem, tho.
a6bd06d
to
a90f8ff
Compare
- Untangle imports. - Inline the entirely of ListLock into with_inner(). - Add documentation for feature. Signed-off-by: John Nunley <[email protected]>
The current no-std implementation is somewhat ineffecient, potentially
broken and relies on some slow data structures. The main reason why we
use this implementation is because we don't have a way to "lock" the
linked list, since there's no way to lock things in no-std. However,
many embedded platforms have a concept of a "critical section" that can
be used to exclusively lock something.
This PR adds an option to the "std" implementation that replaces the
existing Mutex with a usage of the critical-section crate. This is
enabled with the "critical-section" feature. This allows us to have the
advantages of the std-based implementation without needing to rely on
std for platforms that don't have it.