From e325825f01f47a89ca450945dd58e8d184984360 Mon Sep 17 00:00:00 2001 From: Weijia Jiang Date: Thu, 21 Sep 2023 00:41:33 +0800 Subject: [PATCH] use grain instead --- tokio/src/runtime/task/list.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tokio/src/runtime/task/list.rs b/tokio/src/runtime/task/list.rs index d9ea132f4b7..7736abd331a 100644 --- a/tokio/src/runtime/task/list.rs +++ b/tokio/src/runtime/task/list.rs @@ -157,9 +157,9 @@ impl OwnedTasks { // 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