Rename Freeze
to FreezeLock
This commit is contained in:
parent
50f0d666d3
commit
a3ad045ea4
4 changed files with 14 additions and 12 deletions
|
@ -62,7 +62,7 @@ pub use vec::{AppendOnlyIndexVec, AppendOnlyVec};
|
||||||
mod vec;
|
mod vec;
|
||||||
|
|
||||||
mod freeze;
|
mod freeze;
|
||||||
pub use freeze::{Freeze, FreezeReadGuard, FreezeWriteGuard};
|
pub use freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard};
|
||||||
|
|
||||||
mod mode {
|
mod mode {
|
||||||
use super::Ordering;
|
use super::Ordering;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::{
|
||||||
///
|
///
|
||||||
/// Unlike `RwLock`, it can be used to prevent mutation past a point.
|
/// Unlike `RwLock`, it can be used to prevent mutation past a point.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Freeze<T> {
|
pub struct FreezeLock<T> {
|
||||||
data: UnsafeCell<T>,
|
data: UnsafeCell<T>,
|
||||||
frozen: AtomicBool,
|
frozen: AtomicBool,
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ pub struct Freeze<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
unsafe impl<T: DynSync + DynSend> DynSync for Freeze<T> {}
|
unsafe impl<T: DynSync + DynSend> DynSync for FreezeLock<T> {}
|
||||||
|
|
||||||
impl<T> Freeze<T> {
|
impl<T> FreezeLock<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(value: T) -> Self {
|
pub fn new(value: T) -> Self {
|
||||||
Self { data: UnsafeCell::new(value), frozen: AtomicBool::new(false), lock: RwLock::new(()) }
|
Self { data: UnsafeCell::new(value), frozen: AtomicBool::new(false), lock: RwLock::new(()) }
|
||||||
|
@ -71,8 +71,8 @@ impl<T> Freeze<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A guard holding shared access to a `Freeze` which is in a locked state or frozen.
|
/// A guard holding shared access to a `FreezeLock` which is in a locked state or frozen.
|
||||||
#[must_use = "if unused the Freeze may immediately unlock"]
|
#[must_use = "if unused the FreezeLock may immediately unlock"]
|
||||||
pub struct FreezeReadGuard<'a, T> {
|
pub struct FreezeReadGuard<'a, T> {
|
||||||
_lock_guard: Option<ReadGuard<'a, ()>>,
|
_lock_guard: Option<ReadGuard<'a, ()>>,
|
||||||
data: &'a T,
|
data: &'a T,
|
||||||
|
@ -86,8 +86,8 @@ impl<'a, T: 'a> Deref for FreezeReadGuard<'a, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A guard holding mutable access to a `Freeze` which is in a locked state or frozen.
|
/// A guard holding mutable access to a `FreezeLock` which is in a locked state or frozen.
|
||||||
#[must_use = "if unused the Freeze may immediately unlock"]
|
#[must_use = "if unused the FreezeLock may immediately unlock"]
|
||||||
pub struct FreezeWriteGuard<'a, T> {
|
pub struct FreezeWriteGuard<'a, T> {
|
||||||
_lock_guard: WriteGuard<'a, ()>,
|
_lock_guard: WriteGuard<'a, ()>,
|
||||||
data: &'a mut T,
|
data: &'a mut T,
|
||||||
|
|
|
@ -7,7 +7,9 @@ use rustc_codegen_ssa::traits::CodegenBackend;
|
||||||
use rustc_codegen_ssa::CodegenResults;
|
use rustc_codegen_ssa::CodegenResults;
|
||||||
use rustc_data_structures::steal::Steal;
|
use rustc_data_structures::steal::Steal;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::{AppendOnlyIndexVec, Freeze, Lrc, OnceLock, RwLock, WorkerLocal};
|
use rustc_data_structures::sync::{
|
||||||
|
AppendOnlyIndexVec, FreezeLock, Lrc, OnceLock, RwLock, WorkerLocal,
|
||||||
|
};
|
||||||
use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
|
use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||||
use rustc_hir::definitions::Definitions;
|
use rustc_hir::definitions::Definitions;
|
||||||
use rustc_incremental::DepGraphFuture;
|
use rustc_incremental::DepGraphFuture;
|
||||||
|
@ -197,7 +199,7 @@ impl<'tcx> Queries<'tcx> {
|
||||||
self.codegen_backend().metadata_loader(),
|
self.codegen_backend().metadata_loader(),
|
||||||
stable_crate_id,
|
stable_crate_id,
|
||||||
)) as _);
|
)) as _);
|
||||||
let definitions = Freeze::new(Definitions::new(stable_crate_id));
|
let definitions = FreezeLock::new(Definitions::new(stable_crate_id));
|
||||||
let source_span = AppendOnlyIndexVec::new();
|
let source_span = AppendOnlyIndexVec::new();
|
||||||
let _id = source_span.push(krate.spans.inner_span);
|
let _id = source_span.push(krate.spans.inner_span);
|
||||||
debug_assert_eq!(_id, CRATE_DEF_ID);
|
debug_assert_eq!(_id, CRATE_DEF_ID);
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::utils::NativeLibKind;
|
||||||
use crate::Session;
|
use crate::Session;
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::owned_slice::OwnedSlice;
|
use rustc_data_structures::owned_slice::OwnedSlice;
|
||||||
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, Freeze, RwLock};
|
use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock, RwLock};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE};
|
||||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
|
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
|
||||||
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
||||||
|
@ -261,5 +261,5 @@ pub struct Untracked {
|
||||||
pub cstore: RwLock<Box<CrateStoreDyn>>,
|
pub cstore: RwLock<Box<CrateStoreDyn>>,
|
||||||
/// Reference span for definitions.
|
/// Reference span for definitions.
|
||||||
pub source_span: AppendOnlyIndexVec<LocalDefId, Span>,
|
pub source_span: AppendOnlyIndexVec<LocalDefId, Span>,
|
||||||
pub definitions: Freeze<Definitions>,
|
pub definitions: FreezeLock<Definitions>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue