From 3ad5b6df1a01c09da25a393d5857e99f71e5c179 Mon Sep 17 00:00:00 2001 From: Motoyuki Kimura Date: Mon, 22 Jul 2024 00:26:36 +0900 Subject: [PATCH] runtime: add cfg for loom specific code (#6694) --- tokio/src/runtime/blocking/pool.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tokio/src/runtime/blocking/pool.rs b/tokio/src/runtime/blocking/pool.rs index 20b23e002..bc854f36d 100644 --- a/tokio/src/runtime/blocking/pool.rs +++ b/tokio/src/runtime/blocking/pool.rs @@ -264,8 +264,12 @@ impl BlockingPool { // Loom requires that execution be deterministic, so sort by thread ID before joining. // (HashMaps use a randomly-seeded hash function, so the order is nondeterministic) - let mut workers: Vec<(usize, thread::JoinHandle<()>)> = workers.into_iter().collect(); - workers.sort_by_key(|(id, _)| *id); + #[cfg(loom)] + let workers: Vec<(usize, thread::JoinHandle<()>)> = { + let mut workers: Vec<_> = workers.into_iter().collect(); + workers.sort_by_key(|(id, _)| *id); + workers + }; for (_id, handle) in workers { let _ = handle.join();