Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the octillion test use more threads #1121

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tests/octillion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ fn two_threads<F: Send + FnOnce() -> R, R: Send>(f: F) -> R {
// FIXME: If we don't use at least two threads, then we end up walking
// through the entire iterator sequentially, without the benefit of any
// short-circuiting. We probably don't want testing to wait that long. ;)
let builder = rayon::ThreadPoolBuilder::new().num_threads(2);
let pool = builder.build().unwrap();

pool.install(f)
if rayon::current_num_threads() < 2 {
use std::sync::OnceLock;
static POOL: OnceLock<rayon::ThreadPool> = OnceLock::new();
let pool = POOL.get_or_init(|| {
let builder = rayon::ThreadPoolBuilder::new().num_threads(2);
builder.build().unwrap()
});
pool.install(f)
} else {
f()
}
}

#[test]
Expand Down