1
Fork 0

compiler/rustc_data_structures/src/sync.rs: remove atomics, but not AtomicU64!

This commit is contained in:
Askar Safin 2025-02-11 08:57:36 +03:00
parent 8f684c9db7
commit 4a2c7f48b5
4 changed files with 4 additions and 11 deletions

View file

@ -20,11 +20,6 @@
//! | ----------------------- | ------------------- | ------------------------------- | //! | ----------------------- | ------------------- | ------------------------------- |
//! | `LRef<'a, T>` [^2] | `&'a mut T` | `&'a T` | //! | `LRef<'a, T>` [^2] | `&'a mut T` | `&'a T` |
//! | | | | //! | | | |
//! | `AtomicBool` | `Cell<bool>` | `atomic::AtomicBool` |
//! | `AtomicU32` | `Cell<u32>` | `atomic::AtomicU32` |
//! | `AtomicU64` | `Cell<u64>` | `atomic::AtomicU64` |
//! | `AtomicUsize` | `Cell<usize>` | `atomic::AtomicUsize` |
//! | | | |
//! | `Lock<T>` | `RefCell<T>` | `RefCell<T>` or | //! | `Lock<T>` | `RefCell<T>` | `RefCell<T>` or |
//! | | | `parking_lot::Mutex<T>` | //! | | | `parking_lot::Mutex<T>` |
//! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` | //! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` |
@ -107,7 +102,6 @@ pub use std::sync::OnceLock;
// Use portable AtomicU64 for targets without native 64-bit atomics // Use portable AtomicU64 for targets without native 64-bit atomics
#[cfg(target_has_atomic = "64")] #[cfg(target_has_atomic = "64")]
pub use std::sync::atomic::AtomicU64; pub use std::sync::atomic::AtomicU64;
pub use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize};
pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode}; pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode};
pub use parking_lot::{ pub use parking_lot::{

View file

@ -3,9 +3,9 @@ use std::intrinsics::likely;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::ptr::NonNull; use std::ptr::NonNull;
use std::sync::atomic::Ordering; use std::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{AtomicBool, DynSend, DynSync, ReadGuard, RwLock, WriteGuard}; use crate::sync::{DynSend, DynSync, ReadGuard, RwLock, WriteGuard};
/// A type which allows mutation using a lock until /// A type which allows mutation using a lock until
/// the value is frozen and can be accessed lock-free. /// the value is frozen and can be accessed lock-free.

View file

@ -4,14 +4,14 @@ use std::fmt::Debug;
use std::hash::Hash; use std::hash::Hash;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::Ordering; use std::sync::atomic::{AtomicU32, Ordering};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef}; use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef};
use rustc_data_structures::sharded::{self, Sharded}; use rustc_data_structures::sharded::{self, Sharded};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock}; use rustc_data_structures::sync::{AtomicU64, Lock};
use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordMap;
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable}; use rustc_macros::{Decodable, Encodable};

View file

@ -46,7 +46,6 @@ are implemented differently depending on whether `parallel-compiler` is true.
| data structure | parallel | non-parallel | | data structure | parallel | non-parallel |
| -------------------------------- | --------------------------------------------------- | ------------ | | -------------------------------- | --------------------------------------------------- | ------------ |
| Atomic{Bool}/{Usize}/{U32}/{U64} | std::sync::atomic::Atomic{Bool}/{Usize}/{U32}/{U64} | (std::cell::Cell<bool/usize/u32/u64>) |
| OnceCell | std::sync::OnceLock | std::cell::OnceCell | | OnceCell | std::sync::OnceLock | std::cell::OnceCell |
| Lock\<T> | (parking_lot::Mutex\<T>) | (std::cell::RefCell) | | Lock\<T> | (parking_lot::Mutex\<T>) | (std::cell::RefCell) |
| RwLock\<T> | (parking_lot::RwLock\<T>) | (std::cell::RefCell) | | RwLock\<T> | (parking_lot::RwLock\<T>) | (std::cell::RefCell) |