Skip to content

Commit fe3d6a7

Browse files
authored
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
2 parents c630b6b + 0d61e6e commit fe3d6a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/core/src/sync/atomic.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,11 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
26482648
///
26492649
/// pub fn lock(&self) {
26502650
/// // Wait until the old value is `false`.
2651-
/// while self.flag.compare_and_swap(false, true, Ordering::Relaxed) != false {}
2651+
/// while self
2652+
/// .flag
2653+
/// .compare_exchange_weak(false, true, Ordering::Relaxed, Ordering::Relaxed)
2654+
/// .is_err()
2655+
/// {}
26522656
/// // This fence synchronizes-with store in `unlock`.
26532657
/// fence(Ordering::Acquire);
26542658
/// }
@@ -2710,7 +2714,7 @@ pub fn fence(order: Ordering) {
27102714
/// Without `compiler_fence`, the `assert_eq!` in following code
27112715
/// is *not* guaranteed to succeed, despite everything happening in a single thread.
27122716
/// To see why, remember that the compiler is free to swap the stores to
2713-
/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both
2717+
/// `IMPORTANT_VARIABLE` and `IS_READY` since they are both
27142718
/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right
27152719
/// after `IS_READY` is updated, then the signal handler will see
27162720
/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`.

0 commit comments

Comments
 (0)