Skip to content

Commit

Permalink
use grain instead
Browse files Browse the repository at this point in the history
  • Loading branch information
wathenjiang committed Sep 20, 2023
1 parent 3bb484e commit e325825
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/runtime/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ impl<S: 'static> OwnedTasks<S> {
// The first iteration of the loop was unrolled so it can set the
// closed bool.
self.closed.store(true, Ordering::Release);
for i in start..self.lists.len() + start {
for i in start..self.grain as usize + start {
loop {
let task = match self.lists[i % (self.lists.len())].lock().pop_back() {
let task = match self.lists[i & (self.grain - 1) as usize].lock().pop_back() {
Some(task) => {
self.count.fetch_sub(1, Ordering::Relaxed);
task
Expand Down

0 comments on commit e325825

Please sign in to comment.