-
Notifications
You must be signed in to change notification settings - Fork 36
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
On same deadline, items queued first have priority #205
base: master
Are you sure you want to change the base?
Conversation
@amcandio Please rebase on |
@notgull rebased! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #205 +/- ##
==========================================
+ Coverage 85.44% 86.22% +0.77%
==========================================
Files 13 15 +2
Lines 1876 2069 +193
==========================================
+ Hits 1603 1784 +181
- Misses 273 285 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@notgull any update on this? |
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.
Apologies, I was distracted.
@@ -278,8 +278,11 @@ impl TimerWheel { | |||
impl std::cmp::Ord for TimeoutData { | |||
#[inline] | |||
fn cmp(&self, other: &Self) -> std::cmp::Ordering { | |||
// earlier values have priority | |||
self.deadline.cmp(&other.deadline).reverse() | |||
// earlier values have priority, on same deadline items queued first have priority |
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.
Please use proper capitalization and punctuation for comments.
When multiple are registered at the same time, those registered first should have priority to make scheduling behavior easier to predict. I don't think this should be added as documented behavior to prevent users from depending on it.
Once nice to have follow up would be to start supporting custom prioritization as tie-breaker so users can define their own to handle tie-breaking. Right now users depend on tweaking expire timestamps to get same effect, which is not clean.