rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
This commit is contained in:
parent
b537c1f175
commit
a12f50ddc4
@ -143,6 +143,20 @@ pub fn fetch_or(&self, val: bool, _: Ordering) -> bool {
|
|||||||
self.0.set(val);
|
self.0.set(val);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
pub fn fetch_update(
|
||||||
|
&self,
|
||||||
|
_order_set: Ordering,
|
||||||
|
_order_get: Ordering,
|
||||||
|
mut f: impl FnMut(bool) -> Option<bool>,
|
||||||
|
) -> Result<bool, bool> {
|
||||||
|
let prev = self.0.get();
|
||||||
|
if let Some(next) = f(prev) {
|
||||||
|
self.0.set(next);
|
||||||
|
Ok(prev)
|
||||||
|
} else {
|
||||||
|
Err(prev)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Copy + PartialEq> Atomic<T> {
|
impl<T: Copy + PartialEq> Atomic<T> {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::owned_slice::OwnedSlice;
|
use rustc_data_structures::owned_slice::OwnedSlice;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
|
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnhashMap;
|
||||||
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
||||||
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
|
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
|
||||||
@ -40,7 +40,7 @@
|
|||||||
use std::iter::TrustedLen;
|
use std::iter::TrustedLen;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::Ordering;
|
||||||
use std::{io, iter, mem};
|
use std::{io, iter, mem};
|
||||||
|
|
||||||
pub(super) use cstore_impl::provide;
|
pub(super) use cstore_impl::provide;
|
||||||
|
Loading…
Reference in New Issue
Block a user