-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
48 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Initialize the rayon threadpool once, before we need it. | ||
//! | ||
//! The `uv` crate sets [`RAYON_PARALLELISM`] from the user settings, and the extract and install | ||
//! code initialize the threadpool lazily only if they are actually used by calling | ||
//! `LazyLock::force(&RAYON_INITIALIZE)`. | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
use std::sync::LazyLock; | ||
|
||
/// The number of threads for the rayon threadpool. | ||
/// | ||
/// The default of 0 makes rayon use its default. | ||
pub static RAYON_PARALLELISM: AtomicUsize = AtomicUsize::new(0); | ||
|
||
/// Initialize the threadpool lazily. Always call before using rayon the potentially first time. | ||
pub static RAYON_INITIALIZE: LazyLock<()> = LazyLock::new(|| { | ||
rayon::ThreadPoolBuilder::new() | ||
.num_threads(RAYON_PARALLELISM.load(Ordering::SeqCst)) | ||
.build_global() | ||
.expect("failed to initialize global rayon pool"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters