Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example
This commit is contained in:
@@ -2648,7 +2648,11 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
|
|||||||
///
|
///
|
||||||
/// pub fn lock(&self) {
|
/// pub fn lock(&self) {
|
||||||
/// // Wait until the old value is `false`.
|
/// // 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`.
|
/// // This fence synchronizes-with store in `unlock`.
|
||||||
/// fence(Ordering::Acquire);
|
/// fence(Ordering::Acquire);
|
||||||
/// }
|
/// }
|
||||||
|
|||||||
Reference in New Issue
Block a user