mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
Replace yield_now() with spin loop hint
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
// so we have to stick to C++11 emulation from exiting research.
|
||||
|
||||
use std::sync::atomic::Ordering::*;
|
||||
use std::thread::{spawn, yield_now};
|
||||
use std::thread::spawn;
|
||||
use std::sync::atomic::{fence, AtomicUsize};
|
||||
|
||||
// Spins and yields until until it reads value
|
||||
// Spins until it reads value
|
||||
fn reads_value(loc: &AtomicUsize, val: usize) -> usize {
|
||||
while loc.load(Relaxed) != val {
|
||||
yield_now();
|
||||
std::hint::spin_loop();
|
||||
}
|
||||
val
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::*;
|
||||
use std::thread::{spawn, yield_now};
|
||||
use std::thread::spawn;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct EvilSend<T>(pub T);
|
||||
@@ -37,10 +37,10 @@ fn static_atomic(val: usize) -> &'static AtomicUsize {
|
||||
ret
|
||||
}
|
||||
|
||||
// Spins and yields until until acquires a pre-determined value
|
||||
// Spins until acquires a pre-determined value
|
||||
fn acquires_value(loc: &AtomicUsize, val: usize) -> usize {
|
||||
while loc.load(Acquire) != val {
|
||||
yield_now();
|
||||
std::hint::spin_loop();
|
||||
}
|
||||
val
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user