mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Consistently use Ordering::Relaxed
for standalone atomic use cases (#14190)
This commit is contained in:
parent
fe11ceedfa
commit
9fba7a4768
3 changed files with 6 additions and 6 deletions
|
@ -62,7 +62,7 @@ pub static RAYON_PARALLELISM: AtomicUsize = AtomicUsize::new(0);
|
||||||
/// `LazyLock::force(&RAYON_INITIALIZE)`.
|
/// `LazyLock::force(&RAYON_INITIALIZE)`.
|
||||||
pub static RAYON_INITIALIZE: LazyLock<()> = LazyLock::new(|| {
|
pub static RAYON_INITIALIZE: LazyLock<()> = LazyLock::new(|| {
|
||||||
rayon::ThreadPoolBuilder::new()
|
rayon::ThreadPoolBuilder::new()
|
||||||
.num_threads(RAYON_PARALLELISM.load(Ordering::SeqCst))
|
.num_threads(RAYON_PARALLELISM.load(Ordering::Relaxed))
|
||||||
.stack_size(min_stack_size())
|
.stack_size(min_stack_size())
|
||||||
.build_global()
|
.build_global()
|
||||||
.expect("failed to initialize global rayon pool");
|
.expect("failed to initialize global rayon pool");
|
||||||
|
|
|
@ -13,12 +13,12 @@ pub static ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
/// Enable user-facing warnings.
|
/// Enable user-facing warnings.
|
||||||
pub fn enable() {
|
pub fn enable() {
|
||||||
ENABLED.store(true, std::sync::atomic::Ordering::SeqCst);
|
ENABLED.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable user-facing warnings.
|
/// Disable user-facing warnings.
|
||||||
pub fn disable() {
|
pub fn disable() {
|
||||||
ENABLED.store(false, std::sync::atomic::Ordering::SeqCst);
|
ENABLED.store(false, std::sync::atomic::Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Warn a user, if warnings are enabled.
|
/// Warn a user, if warnings are enabled.
|
||||||
|
@ -28,7 +28,7 @@ macro_rules! warn_user {
|
||||||
use $crate::anstream::eprintln;
|
use $crate::anstream::eprintln;
|
||||||
use $crate::owo_colors::OwoColorize;
|
use $crate::owo_colors::OwoColorize;
|
||||||
|
|
||||||
if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) {
|
if $crate::ENABLED.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
let message = format!("{}", format_args!($($arg)*));
|
let message = format!("{}", format_args!($($arg)*));
|
||||||
let formatted = message.bold();
|
let formatted = message.bold();
|
||||||
eprintln!("{}{} {formatted}", "warning".yellow().bold(), ":".bold());
|
eprintln!("{}{} {formatted}", "warning".yellow().bold(), ":".bold());
|
||||||
|
@ -46,7 +46,7 @@ macro_rules! warn_user_once {
|
||||||
use $crate::anstream::eprintln;
|
use $crate::anstream::eprintln;
|
||||||
use $crate::owo_colors::OwoColorize;
|
use $crate::owo_colors::OwoColorize;
|
||||||
|
|
||||||
if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) {
|
if $crate::ENABLED.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
if let Ok(mut states) = $crate::WARNINGS.lock() {
|
if let Ok(mut states) = $crate::WARNINGS.lock() {
|
||||||
let message = format!("{}", format_args!($($arg)*));
|
let message = format!("{}", format_args!($($arg)*));
|
||||||
if states.insert(message.clone()) {
|
if states.insert(message.clone()) {
|
||||||
|
|
|
@ -400,7 +400,7 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
|
||||||
}))?;
|
}))?;
|
||||||
|
|
||||||
// Don't initialize the rayon threadpool yet, this is too costly when we're doing a noop sync.
|
// Don't initialize the rayon threadpool yet, this is too costly when we're doing a noop sync.
|
||||||
uv_configuration::RAYON_PARALLELISM.store(globals.concurrency.installs, Ordering::SeqCst);
|
uv_configuration::RAYON_PARALLELISM.store(globals.concurrency.installs, Ordering::Relaxed);
|
||||||
|
|
||||||
debug!("uv {}", uv_cli::version::uv_self_version());
|
debug!("uv {}", uv_cli::version::uv_self_version());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue