From 31c01415cbb1793ae9492f40bbdd917cfe8d1fa5 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Tue, 17 May 2022 20:04:18 +0100 Subject: [PATCH] Replace yield_now() with spin loop hint --- tests/compile-fail/weak_memory/cpp20_rwc_syncs.rs | 6 +++--- tests/run-pass/weak_memory/consistency.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/compile-fail/weak_memory/cpp20_rwc_syncs.rs b/tests/compile-fail/weak_memory/cpp20_rwc_syncs.rs index b9e395fd7741..423d0e0e8ffb 100644 --- a/tests/compile-fail/weak_memory/cpp20_rwc_syncs.rs +++ b/tests/compile-fail/weak_memory/cpp20_rwc_syncs.rs @@ -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 } diff --git a/tests/run-pass/weak_memory/consistency.rs b/tests/run-pass/weak_memory/consistency.rs index 67f0e8d35dd3..fa13803830f5 100644 --- a/tests/run-pass/weak_memory/consistency.rs +++ b/tests/run-pass/weak_memory/consistency.rs @@ -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(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 }