Replace deprecated compare_and_swap by compare_exchange_weak in core::sync::atomic::fence example

This commit is contained in:
Júnior Bassani 2021-07-06 10:50:17 -03:00
parent d7901f37bb
commit a87fb18027
No known key found for this signature in database
GPG Key ID: 2642597B3689FE49

View File

@ -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);
/// }