Replace yield_now() with spin loop hint

This commit is contained in:
Andy Wang 2022-05-17 20:04:18 +01:00
parent e2002b4c65
commit 31c01415cb
No known key found for this signature in database
GPG key ID: 181B49F9F38F3374
2 changed files with 6 additions and 6 deletions

View file

@ -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
}

View file

@ -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
}