about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-05-08 15:12:45 -0700
committerMichael Howell <michael@notriddle.com>2023-05-25 08:15:04 -0700
commita12f50ddc4ed73cbca436827ae3958a104d915d3 (patch)
treeceed17a4ced20016d35dfbd4c7676402f7184500 /compiler/rustc_data_structures/src
parentb537c1f1756b43228c3c392a54ddec91b0f1d205 (diff)
downloadrust-a12f50ddc4ed73cbca436827ae3958a104d915d3.tar.gz
rust-a12f50ddc4ed73cbca436827ae3958a104d915d3.zip
rustc_metadata: use configurable AtomicBool for privateness flag
This switches to using a `Cell` for single-threaded rustc.
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/sync.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs
index 6c3197d8ec2..df8285cc729 100644
--- a/compiler/rustc_data_structures/src/sync.rs
+++ b/compiler/rustc_data_structures/src/sync.rs
@@ -143,6 +143,20 @@ cfg_if! {
                 self.0.set(val);
                 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> {