Skip to content
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

time: small implementation cleanups #6517

Merged
merged 11 commits into from
May 1, 2024
Merged
Prev Previous commit
Next Next commit
time: use constant instead of hard-coded values
  • Loading branch information
paolobarbolini committed Apr 25, 2024
commit 404aafc08a4c72b2eede6d741e3d614fce7dc1c0
2 changes: 1 addition & 1 deletion tokio/src/runtime/time/wheel/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Level {
let now_slot = (now / slot_range(self.level)) as usize;
let occupied = self.occupied.rotate_right(now_slot as u32);
let zeros = occupied.trailing_zeros() as usize;
let slot = (zeros + now_slot) % 64;
let slot = (zeros + now_slot) % LEVEL_MULT;

Some(slot)
}
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/time/wheel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn level_for(elapsed: u64, when: u64) -> usize {
let leading_zeros = masked.leading_zeros() as usize;
let significant = 63 - leading_zeros;

significant / 6
significant / NUM_LEVELS
}

#[cfg(all(test, not(loom)))]
Expand Down