runtime: add cfg for loom specific code (#6694)

This commit is contained in:
Motoyuki Kimura
2024-07-21 17:26:36 +02:00
committed by GitHub
parent 1be8a8e691
commit 3ad5b6df1a
+6 -2
View File
@@ -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();