Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example
This commit is contained in:
parent
d7901f37bb
commit
a87fb18027
@ -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);
|
||||
/// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user