-
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
feat: Rework the internal structure of the event-listener crate #51
Conversation
b5d631a
to
b0ffcac
Compare
ok, so some changes do affect lifetimes and sprinkle |
@@ -188,7 +188,7 @@ impl Inner { | |||
match next { | |||
None => self.tail = prev, | |||
Some(n) => unsafe { | |||
n.as_ref().next.set(prev); | |||
n.as_ref().prev.set(prev); |
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.
what happens here?
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.
There was a bug in there that was causing the MIRI issues. It should be fixed now.
|
This move abstracts them to be a sub-module of the inner list.
Ideally, we should have as few dependencies as possible. This change inlines most of the logic from `slab` that we used into the `ListenerSlab` struct.
Everything from that crate can either be inlined or ignored. I also fix a bug with the list implementation as well.
- Renames "list.rs" and the "list" folder to "no_std" - Uses `no_std` as the `sys` module in preparation for the `std` module - Inlines `sync.rs` into `lib.rs`
First part of EventListener reworks. The idea here is that, in the future, we can add an "EventListenerRef" structure that just takes an "&'a Inner" rather than an "Arc<Inner>". This way, you don't need to do an atomic clone for listening.
This optimization is inspired by what futures_lite does for the block_on function. This should prevent users from dealing with the overhead of creating a parker and unparker every time wait() is called.
The EventListener for the upcoming libstd-based implementation needs to be pinned, so this commit sets up the infrastructure for the pinned EventListener. This is a breaking change.
This implementation is around 20% faster than the no_std one, according to benchmarks. Therefore, we should use it where we can.
4150045
to
bc07d43
Compare
I've split the |
thanks, looks overall LGTM. |
Alright, here we go again.
This PR once again reworks the internal structure of
event-listener
. An intrusive linked list is the fastest way to handle an event queue, but isn't available in libstd. Therefore, this PR reworks the internals such that the implementation of event handling used depends on whether or not the libstd feature is enabled:std
is enabled, then it uses the intrusive linked list.std
isn't enabled, then it falls back to the currentmaster
strategy of using a linked list arena falling back to an atomic queue.I'm pretty happy with this iteration at this stage. Draft because I still need to refine the tests.