Skip to content

Commit a87fb18

Browse files
committed
Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example
1 parent d7901f3 commit a87fb18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

library/core/src/sync/atomic.rs

+5-1
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
/// }

0 commit comments

Comments
 (0)