Skip to content

Commit

Permalink
runtime: add cfg for loom specific code (#6694)
Browse files Browse the repository at this point in the history
  • Loading branch information
mox692 authored Jul 21, 2024
1 parent 1be8a8e commit 3ad5b6d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tokio/src/runtime/blocking/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3ad5b6d

Please sign in to comment.