-
Notifications
You must be signed in to change notification settings - Fork 222
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
Fix deboucing hight cpu usage #178
Conversation
I'll let @dfaust review more in depth. I've read the diff and tested some of it and it seems sound, but I don't feel confident judging much more than that! One tiny stylistic nitpick, though: given the |
Looks good to me. But I have to admit, I hadn't looked at that code in a long time. What confused me was the variable |
@dfaust Not exactly. If we end up here: https://github.com/vemoo/notify/blob/ac6430f9d95e33371ef82660528596598c8933b6/src/debounce/timer.rs#L115-L119 it's because we know when the next event should fire, and we also know that there can't be an event before that. I initially thought of just using When we don't yet know when the next event is we end up here: |
@vemoo Yes, you're right. Maybe changing the comments will make things easier to understand.
|
That won't happen unless the delay is really small, because the |
What I meant was that both Anyways, I'm going to merge this now because it's a great improvement. Thank you very much! |
Yeah, I just realised that |
Thank you! I'll go release this later today. |
This are the changes
Sender
inWatchTimer
andReciever
withBinaryHeap
inScheduleWorker
with aVecDeque
shared behind aMutex
BinaryHeap
is not needed because the events are already sorted