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

This commit is contained in:
Motoyuki Kimura 2024-07-22 00:26:36 +09:00 committed by GitHub
parent 1be8a8e691
commit 3ad5b6df1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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();