feat(cordyceps): singly-linked intrusive SortedList#520
Conversation
This PR implements: * A new method for `TransferStack` that reports whether the list was previously empty * A new type, `SortedList`, that is a sorted singly-linked-list
|
These changes are exercised in jamesmunns/embassy#1 as well. |
|
It occurs to me that if we want to not have the insert operation be O(n), but we also don't want to go with a full intrusive tree implementation, we could probably use a skip list and binary search. If we went down that route, though, we would have to go with a // in sorted list module
pub struct Links<T> {
layer_0: stack::Links<T>,
skip_layers: [Option<NonNull<T>>; NUM_SKIP_LAYERS],
}
// Make anything that has sorted-list links "count" as having stack links too
impl<T: Linked<stack::Links<T>>> for T where T: Linked<Links<T>> {
// ... some wacky unsafe code to offset the pointers returned by the
// `Linked<Links<T>>` impl to get the `stack::Links` out of them, which
// i didn't want to write, but i'm sure is possible...
} |
|
I will likely not plan to add any Smarter impls for SortedList for now, but if you would like me to leave room for other impls (SkipSortedList?) somewhere, I can do so! |
|
@hawkw I think I've addressed all comments, back to you, let me know if I can help get this published! |
hawkw
left a comment
There was a problem hiding this comment.
Looks good to me overall! I had some minor nits, mostly about the comments, but this should be good to merge once those are addressed.
Would you mind changing the commit message to something like
feat(cordyceps): singly-linked intrusive
SortedList
or something before merging? that way, it should look nice when generating the changelog...
SortedList
This PR implements:
TransferStackthat reports whether the list was previously emptySortedList, that is a sorted singly-linked-listThese are changes I am making for experimentation with embassy's scheduler, which I am using
cordycepsfor.These changes are currently functional and minimally tested, but probably could use tweaks to better fit naturally in the library.