Replace yield_now() with spin loop hint
This commit is contained in:
parent
e2002b4c65
commit
31c01415cb
2 changed files with 6 additions and 6 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue