summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_data_structures/src/sync/vec.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_data_structures/src/sync/vec.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_data_structures/src/sync/vec.rs')
-rw-r--r--compiler/rustc_data_structures/src/sync/vec.rs28
1 files changed, 7 insertions, 21 deletions
diff --git a/compiler/rustc_data_structures/src/sync/vec.rs b/compiler/rustc_data_structures/src/sync/vec.rs
index e36dded9e..314496ce9 100644
--- a/compiler/rustc_data_structures/src/sync/vec.rs
+++ b/compiler/rustc_data_structures/src/sync/vec.rs
@@ -43,37 +43,23 @@ impl<I: Idx, T: Copy> AppendOnlyIndexVec<I, T> {
#[derive(Default)]
pub struct AppendOnlyVec<T: Copy> {
- #[cfg(not(parallel_compiler))]
- vec: elsa::vec::FrozenVec<T>,
- #[cfg(parallel_compiler)]
- vec: elsa::sync::LockFreeFrozenVec<T>,
+ vec: parking_lot::RwLock<Vec<T>>,
}
impl<T: Copy> AppendOnlyVec<T> {
pub fn new() -> Self {
- Self {
- #[cfg(not(parallel_compiler))]
- vec: elsa::vec::FrozenVec::new(),
- #[cfg(parallel_compiler)]
- vec: elsa::sync::LockFreeFrozenVec::new(),
- }
+ Self { vec: Default::default() }
}
pub fn push(&self, val: T) -> usize {
- #[cfg(not(parallel_compiler))]
- let i = self.vec.len();
- #[cfg(not(parallel_compiler))]
- self.vec.push(val);
- #[cfg(parallel_compiler)]
- let i = self.vec.push(val);
- i
+ let mut v = self.vec.write();
+ let n = v.len();
+ v.push(val);
+ n
}
pub fn get(&self, i: usize) -> Option<T> {
- #[cfg(not(parallel_compiler))]
- return self.vec.get_copy(i);
- #[cfg(parallel_compiler)]
- return self.vec.get(i);
+ self.vec.read().get(i).copied()
}
pub fn iter_enumerated(&self) -> impl Iterator<Item = (usize, T)> + '_ {