sync: use spin_loop_hint instead of yield_now in mpsc (#4037)

This commit is contained in:
Alice Ryhl
2021-08-12 16:03:10 +02:00
committed by GitHub
parent 84c4a6d89f
commit c4e56232ff
+7 -3
View File
@@ -1,6 +1,5 @@
use crate::loom::cell::UnsafeCell; use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize}; use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
use crate::loom::thread;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::ops; use std::ops;
@@ -344,8 +343,13 @@ impl<T> Block<T> {
Err(curr) => curr, Err(curr) => curr,
}; };
// When running outside of loom, this calls `spin_loop_hint`. #[cfg(all(test, loom))]
thread::yield_now(); crate::loom::thread::yield_now();
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
#[cfg(not(all(test, loom)))]
#[allow(deprecated)]
std::sync::atomic::spin_loop_hint();
} }
} }
} }