about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-07-07 12:17:42 +0900
committerGitHub <noreply@github.com>2021-07-07 12:17:42 +0900
commitfe3d6a74d9483a8c0f74c80c3b647e07e5ce7a6d (patch)
tree806541b68bd25beea81ac22d899240c6eaddb20f
parentc630b6b0fc21bf8dfcd49d9e8e675bbde4822a17 (diff)
parent0d61e6e8d68be269c57d1d067f29a8a0e5eb6e29 (diff)
downloadrust-fe3d6a74d9483a8c0f74c80c3b647e07e5ce7a6d.tar.gz
rust-fe3d6a74d9483a8c0f74c80c3b647e07e5ce7a6d.zip
Rollup merge of #86906 - juniorbassani:update-sync-docs, r=yaahc
Replace deprecated compare_and_swap and fix typo in core::sync::atomic::{fence, compiler_fence} docs
-rw-r--r--library/core/src/sync/atomic.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
index f1a115563fd..b673b36c102 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
@@ -2648,7 +2648,11 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
 ///
 ///     pub fn lock(&self) {
 ///         // Wait until the old value is `false`.
-///         while self.flag.compare_and_swap(false, true, Ordering::Relaxed) != false {}
+///         while self
+///             .flag
+///             .compare_exchange_weak(false, true, Ordering::Relaxed, Ordering::Relaxed)
+///             .is_err()
+///         {}
 ///         // This fence synchronizes-with store in `unlock`.
 ///         fence(Ordering::Acquire);
 ///     }
@@ -2710,7 +2714,7 @@ pub fn fence(order: Ordering) {
 /// Without `compiler_fence`, the `assert_eq!` in following code
 /// is *not* guaranteed to succeed, despite everything happening in a single thread.
 /// To see why, remember that the compiler is free to swap the stores to
-/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both
+/// `IMPORTANT_VARIABLE` and `IS_READY` since they are both
 /// `Ordering::Relaxed`. If it does, and the signal handler is invoked right
 /// after `IS_READY` is updated, then the signal handler will see
 /// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`.